For the following code, the possible outputs are ABBCE4E, ABs7E, and ABCBs7E. I'm not sure why the first one doesn't have a 7 in it. When it sends the interrupt signal to the child, wouldn't "s" and "7" be printed? For the second, I don't understand how "s" and "7" are printed but no "C". Does that mean the kill signal reached the child before it could print "C"? For the last one, I'm not also not sure why a 4 would be printed in any case.
void handler(int sig){
printf("s");
exit(7);
}
int forker(int x){
int pid,status;
signal(SIGINT, handler);
printf("A");
if(x > 0) {
pid = fork();
printf("B");
if(pid == 0) {
printf("C");
} else {
kill(pid,SIGINT);
waitpid(pid,&status,0);
printf("%d", WEXITSTATUS(status));
}
}
printf("E");
exit(4);
}