Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Monitoring child processes

by Marshall (Canon)
on Mar 13, 2012 at 15:54 UTC ( #959388=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://959388]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2020-12-04 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (58 votes). Check out past polls.

    Notices?