Re: Should parent's WIFSIGNALED(siginfo->si_status) be true EVEN IF the SIGNAL was caught by the child?

Date

Sat, 22 Sep 2007 13:18:53 -0700

On Saturday 22 September 2007 11:49:09 Michael Kerrisk wrote:> John,>

...snip...

>> If the child terminated by calling exit(), regardless of whether it> was done from inside a signal handler, then WIFEXITED() should test> true, but WIFSIGNALED() will not. If you are seeing otherwise, then> show a *short* program that demonstrates the behavior. (But it seems> unlikely that there would be a kernel bug on this point, so do check> your program carefully!)

Attached is a (somewhat) short program that demonstates the behavior. I simply compile it with 'make sigtest'.

/* * Since sigChld is re-entrant, its okay to have SA_NODEFER, and necessary, * too, since I want to waitpid() on ALL child processes, and since * waitpid() won't block if called after the child croaked, its just simply * a way to affect an orderly shutdown of child processes, avoiding the * zombie state...of course, I could be wrong, and without SA_NODEFER, the * SIGCHLD is only _temporarily_ blocked, then I'll get subsequent SIGCHLDs * after this handler completes...either way, in this case its irrelevant. */ action.sa_flags = SA_SIGINFO | SA_NOCLDSTOP | SA_RESTART | SA_NODEFER; sigaction(SIGCHLD, &action, NULL);