[poe-commits] poe/lib/POE/Resource Signals.pm,1.13,1.14
Brought to you by:
rcaputo
From: <rc...@us...> - 2005-05-15 07:09:55
|
Update of /cvsroot/poe/poe/lib/POE/Resource In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9134/lib/POE/Resource Modified Files: Signals.pm Log Message: Fix SIGCHLD and SIGPIPE so they are IGNOREd by default. In SIGCHLD's case, this means Perl will reap child processes so you don't need to register a SIGCHLD handler if you don't care. In SIGPIPE's case, it means programs won't die if they mistakenly write to a broken pipe. Both situations have occurred since POE stopped setting default handlers for these signals. Index: Signals.pm =================================================================== RCS file: /cvsroot/poe/poe/lib/POE/Resource/Signals.pm,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Signals.pm 2 Feb 2005 04:44:34 -0000 1.13 --- Signals.pm 15 May 2005 07:09:44 -0000 1.14 *************** *** 48,52 **** my $kr_child_procs = exists($INC{'Apache.pm'}) ? 0 : 1; - sub _data_sig_preload { $poe_kernel->[KR_SIGNALS] = \%kr_signals; --- 48,51 ---- *************** *** 106,109 **** --- 105,113 ---- next if $signal =~ /^CH?LD$/ and exists $INC{'Apache.pm'}; + # Reset the signal handler. Some signal handlers are set to + # IGNORE, while most are kept to DEFAULT. The event loop will + # know what to do. + $self->loop_ignore_signal($signal); + $_safe_signals{$signal} = 1; } *************** *** 138,141 **** --- 142,147 ---- } + %_safe_signals = (); + return $finalized_ok; } *************** *** 443,446 **** --- 449,462 ---- } + # Reap child processes. Discard their statuses. Used to prevent + # zombie processes when nobody else is watching for children. See + # POE::Loop::Event for its use. + + sub _data_sig_ignore_sigchld { + my $pid; + 1 while $pid = waitpid(-1, WNOHANG); + $kr_child_procs = !$pid; + } + 1; |