Patch from Jon Schutz to add a proper SIGCHLD repear to Engine::HTTP to fix issue...
Andy Grundman [Fri, 26 Oct 2007 04:44:42 +0000 (04:44 +0000)]
Changes
lib/Catalyst/Engine/HTTP.pm

diff --git a/Changes b/Changes
index 45122e6..5e3846e 100644 (file)
--- a/Changes
+++ b/Changes
@@ -1,6 +1,10 @@
 # This file documents the revision history for Perl extension Catalyst.
 
-5.7011
+5.7012
+        - Fixed Engine::HTTP to use a proper SIGCHLD repear. Should fix issues with 
+          system() calls returning -1 instead of the correct value. (Jon Schutz)
+
+5.7011  2007-10-18 20:40:00
         - Allow multiple restart directories and added option to follow
           symlinks in the HTTP::Restarter engine (Sebastian Willert)
         - Fixed t/optional_http-server-restart.t so it actually tests
index ec4ad86..725992e 100644 (file)
@@ -11,6 +11,7 @@ use NEXT;
 use Socket;
 use IO::Socket::INET ();
 use IO::Select       ();
+use POSIX ":sys_wait_h";
 
 # For PAR
 require Catalyst::Engine::HTTP::Restarter;
@@ -189,7 +190,7 @@ sub run {
     }
 
     my $restart = 0;
-    local $SIG{CHLD} = 'IGNORE';
+    local $SIG{CHLD} = \&_REAPER;
 
     my $allowed = $options->{allowed} || { '127.0.0.1' => '255.255.255.255' };
     my $addr = $host ? inet_aton($host) : INADDR_ANY;
@@ -525,6 +526,12 @@ sub _socket_data {
 
 sub _inet_addr { unpack "N*", inet_aton( $_[0] ) }
 
+sub _REAPER {
+    my $child;
+    while ( ( $child = waitpid( -1,WNOHANG ) ) > 0 ) { }
+    $SIG{CHLD} = \&_REAPER;
+}
+
 =head1 SEE ALSO
 
 L<Catalyst>, L<Catalyst::Engine>.