Search code examples
csignalssigchld

Why we generally ignore SIGCHLD


I was studying about signals and going through this link

https://en.wikipedia.org/wiki/Child_process#cite_note-1

And this is what it says : "The SIGCHLD signal is sent to the parent of a child process when it exits, is interrupted, or resumes after being interrupted. By default the signal is simply ignored"

is there any reason why we ignore SIGCHLD.


Solution

  • Try having kids and you'll understand why sometimes you have to ignore SIGCHLD to maintain your sanity :).

    Jokes aside, all that statement means is that POSIX systems do not define a default signal behavior, other than to ignore it, for SIGCHLD. Compare this with SIGINT, SIGTERM, etc where the default behavior might be to terminate the process.

    See man 7 signal on linux for a list of all signals, all default handlers, and the mapping of signals->default handler.

    Often it makes sense to ignore SIGCHLD because you can know everything you need to know from waitpid.