Old stuff/ecole_etude_fac_de_pau/licence_3/systeme-d-exploitation/tp3/4.c
(Deskargatu)
#include <sys/types.h>
#include <errno.h>
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
void fonction(int n)
{
printf("detourne sigcld\n");
}
int main(int argc, char** argv)
{
struct sigaction action;
action.sa_handler = fonction;
sigemptyset(&action.sa_mask);
if(sigaction(SIGCHLD,&action,NULL) == -1)
{
perror("signal action errror");
exit(-1);
}
pid_t pid;
pid = fork();
if (pid == -1){
perror("fork error");
exit(-1);
}
else if (pid == 0)
{
printf("fils ... \n");
while(1) { sleep(1); }
}
else
{
printf("pere \n");
}
// while(1) { sleep(1); }
return 0;
}