http://qs321.pair.com?node_id=959388


in reply to Monitoring child processes

When you are running a normal program from the shell, it can return back an exit status back to the shell when it quits, exit(12), etc. The same sort of thing can happen when a child process exits. The parent gets a SIGCHLD when the child dies and it can go look at the child's exit status if it wants to.

The child's entry remains in the process table as a place to maintain this status. A child in this state is sometimes called a "zombie" and the process of reading the status is called "reaping" the child. There is an option in waitpid to get the exit status, but in practice most common is to just throw it away (parent doesn't care). So that is what SIGCHLD is about. If you don't care (a) that the child died or (b) what its exit status was, then you can ignore the SIGCHLD signal and the OS will throw the exit status away for you without the parent having to do that.

This behavior is of course OS specific - most portable thing is to explicitly say what you want to have happen (either by installing your signal handler or setting it to "ignore". So if the parent doesn't care about (a) or (b), then there is nothing wrong with having the status "auto-reaped" and discarded.