What is the use of ignoring `SIGCHLD` signal with `sigaction(2)`?
The default behavior of SIGCHLD
is to discard the signal, but the child process is kept as a zombie until the parent calls wait()
(or a variant) to get its termination status.
But if you explicitly call sigaction()
with the disposition SIG_IGN
, that causes it not to turn the child into a zombie -- when the child exits it is reaped immediately. See https://stackoverflow.com/a/7171836/1491895
The POSIX way to get this behavior is by calling sigaction
with handler = SIG_DFL
and flags
containing SA_NOCLDWAIT
. This is in Linux since 2.6.