Skip to content

Commit

Permalink
Per Marc Lehmann's feedback, I have documented how to avoid a
Browse files Browse the repository at this point in the history
potential race condition when catching child processes with
sig_child().  Basically, if you want sig_child() to catch a process,
call the method in the same event handler that forked the process.
Otherwise POE::Kernel may reap the process before sig_child() is
called.
  • Loading branch information
rcaputo committed Apr 28, 2008
1 parent deec39c commit 5fb2bb2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/POE/Kernel.pm
Expand Up @@ -4525,14 +4525,19 @@ watcher can be cleared prematurely by calling sig_child() with just
the PROCESS_ID.
A session may register as many sig_child() handlers as necessary, but
there may only be one per PROCESS_ID.
a session may only have one per PROCESS_ID.
sig_child() watchers are one-shot. They automatically unregister
themselves once the EVENT_NAME has been delivered.
sig_child() watchers keep a session alive for as long as they are
active. This is unique among signal watchers.
Programs that wish to reliably reap child processes should be sure to
call sig_child() before returning from the event handler that forked
the process. Otherwise POE::Kernel may have an opportunity to call
waitpid() before an appropriate event watcher has been registered.
sig_chid() does not return a meaningful value.
sub forked_parent {
Expand Down

0 comments on commit 5fb2bb2

Please sign in to comment.