pcdinh at gmail.com
Tue Feb 15 05:57:09 EST 2011
I currently build a process management system which is able to fork child
processes (fork()) and keep them alive (waitpid() ).
if pid in self.current_workers:
If a child process dies, it should trigger a SIGCHLD signal and a handler is
installed to catch the signal and start a new child process. The code is
nothing special, just can be seen in any Python tutorial you can find on the
signal.signal(signal.SIGHUP, self.handle) # reload
However, this code does not always work as expected. Most of the time, it
works. When a child process exits, the master process receives a SIGCHLD and
restart_child_process() method is invoked automatically to start a new child
process. But the problem is that sometimes, I know a child process exits due
to an unexpected exception (via log file) but it seems that master process
does not know about it. No SIGCHLD and so restart_child_process() is not
triggered. Therefore, no new child process is forked.
Could you please kindly tell me why this happens? Is there any special code
that need being installed to ensure that every dead child will be informed
Mac OSX 10.6
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list