The SA_NOCLDSTOP flag

Regarding the SIGCHLD signal, there is an important point to realize: The default behavior is that, whether a process dies or stops, or a stopped child continues execution (typically via the SIGCONT signal being sent to it), the kernel posts the SIGCHLD signal to its parent.

Perhaps this is useful. The parent is informed of all these events—the child's death, stop-page, or continuation. On the other hand, perhaps we do not want to be spoofed into thinking that our child process has died, when in reality it has just been stopped (or continued).

For such cases, use the SA_NOCLDSTOP flag; it literally means no SIGCHLD on child stop (or resume). Now you will only get the SIGCHLD upon child death.

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.