From 0f42189a5d150ed2fab763320e6bfe9658f8858a Mon Sep 17 00:00:00 2001 From: "ian%hixie.ch" Date: Sat, 20 Sep 2003 17:27:09 +0000 Subject: [PATCH] Change our child process handling behaviour to be more proactive and hopefully less likely to hang. This in theory fixes bug 111987, but who knows. Feel free to reopen that bug if it doesn't help or if it makes things worse (e.g. if you start seeing zombie processes everywhere). It seemed to work for me on Debian. --- webtools/mozbot/mozbot.pl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/webtools/mozbot/mozbot.pl b/webtools/mozbot/mozbot.pl index 7ae674eed3a9..08722b78e685 100755 --- a/webtools/mozbot/mozbot.pl +++ b/webtools/mozbot/mozbot.pl @@ -83,7 +83,7 @@ $SIG{'INT'} = sub { &killed('INT'); }; $SIG{'KILL'} = sub { &killed('KILL'); }; $SIG{'TERM'} = sub { &killed('TERM'); }; -$SIG{'CHLD'} = sub { wait(); }; +$SIG{'CHLD'} = 'IGNORE'; # autoreap children # this allows us to exit() without shutting down (by exec($0)ing) BEGIN { exit() if ((defined($ARGV[0])) and ($ARGV[0] eq '--abort')); } @@ -988,7 +988,7 @@ sub bot_select { &debug("child ${$pipe}->{'BotModules_PID'} completed ${$pipe}->{'BotModules_ChildType'}". (${$pipe}->{'BotModules_Module'}->{'_shutdown'} ? ' (nevermind, module has shutdown)': '')); - waitpid(${$pipe}->{'BotModules_PID'}, 0); + kill 9, ${$pipe}->{'BotModules_PID'}; # ensure child is dead &debug("child ${$pipe}->{'BotModules_PID'} exited."); return if ${$pipe}->{'BotModules_Module'}->{'_shutdown'}; # see unload() eval { @@ -1495,7 +1495,8 @@ sub spawnChild { # had been configured nicks... eval { - exec { $0 } ($0, '--abort'); # do not call shutdown handlers + $0 =~ m/^(.*)$/os; # untaint $0 so that we can call it below: + exec { $1 } ($1, '--abort'); # do not call shutdown handlers # the previous line works because exec() bypasses # the perl object garbarge collection and simply # deallocates all the memory in one go. This means