From fa188eec7be3baf851eb7f41874e1410be87bbc3 Mon Sep 17 00:00:00 2001 From: Yang Tse Date: Mon, 21 Dec 2009 14:43:29 +0000 Subject: dead_child_handler also takes care of reaping pingpong server dead child processes --- tests/ftpserver.pl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index a73db0fac..cb60172e0 100644 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -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; -- cgit v1.2.3