]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
dead_child_handler also takes care of reaping pingpong server dead child processes
authorYang Tse <yangsita@gmail.com>
Mon, 21 Dec 2009 14:43:29 +0000 (14:43 +0000)
committerYang Tse <yangsita@gmail.com>
Mon, 21 Dec 2009 14:43:29 +0000 (14:43 +0000)
tests/ftpserver.pl

index a73db0facc472bf4502755efd561d6c5a0e1a2c8..cb60172e03bd9d38cf71445e0202e9fd388772d6 100644 (file)
@@ -110,6 +110,19 @@ sub exit_signal_handler {
     exit;
 }
 
+#**********************************************************************
+# dead_child_handler takes care of reaping dead child processes.
+#
+sub dead_child_handler {
+    use POSIX ":sys_wait_h";
+    local $!; # preserve errno
+    local $?; # preserve exit status
+    while (waitpid(-1, &WNOHANG) > 0) {
+        select(undef, undef, undef, 0.05);
+    }
+    $SIG{CHLD} = \&dead_child_handler;
+}
+
 #**********************************************************************
 # getlogfilename returns a log file name depending on given arguments.
 #
@@ -204,6 +217,7 @@ if($proto !~ /^(ftp|imap|pop3|smtp)\z/) {
 
 $SIG{INT} = \&exit_signal_handler;
 $SIG{TERM} = \&exit_signal_handler;
+$SIG{CHLD} = \&dead_child_handler;
 
 sub sysread_or_die {
     my $FH     = shift;