aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2009-12-21 14:43:29 +0000
committerYang Tse <yangsita@gmail.com>2009-12-21 14:43:29 +0000
commitfa188eec7be3baf851eb7f41874e1410be87bbc3 (patch)
treef161f52f2b004f76c7b3cfc8b7c2375daa883c0c
parentbdd376398051522a1c930949142d6066f4518a3d (diff)
dead_child_handler also takes care of reaping pingpong server dead child processes
-rw-r--r--tests/ftpserver.pl14
1 files changed, 14 insertions, 0 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index a73db0fac..cb60172e0 100644
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -111,6 +111,19 @@ sub exit_signal_handler {
}
#**********************************************************************
+# 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.
#
sub getlogfilename {
@@ -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;