OK, now I am confused. It seems I do not fully understand how signals work. Consider the example:
Code:
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
void child_status_change_handler(int signum)
{
fprintf(stderr, "Signal recieved!\n");
}
int main()
{
signal(SIGCHLD, &child_status_change_handler);
if (fork() == 0)
execlp("./idler", "idler", "5", NULL);
if (fork() == 0)
execlp("./idler", "idler", "10", NULL);
char buf[1024];
fprintf(stderr, "Press any key to quit...\n");
while (fgets(buf, sizeof(buf), stdin) == NULL);
printf("Terminating...\n");
}
I will receive only ONE signal. The other signal is lost in the void. Why?
Source for idler:
Code:
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main(int argc, char** argv)
{
fprintf(stderr, "Idler will idle for %s seconds...\n", argv[1]);
sleep(strtol(argv[1], NULL, 10));
fprintf(stderr, "Idler terminating...\n");
}