From: Andy Grundman Date: Thu, 27 Oct 2005 17:47:52 +0000 (+0000) Subject: Fixed HTTP engine to exit the restarter process if the parent has died, also fixed... X-Git-Tag: 5.7099_04~1093 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FCatalyst-Runtime.git;a=commitdiff_plain;h=31b426c0de28736be8496c4e1efe831ef390bb2f Fixed HTTP engine to exit the restarter process if the parent has died, also fixed SIGINT for child process, and defaulted delay to 1 just in case --- diff --git a/lib/Catalyst/Engine/HTTP.pm b/lib/Catalyst/Engine/HTTP.pm index e056fff..332e771 100644 --- a/lib/Catalyst/Engine/HTTP.pm +++ b/lib/Catalyst/Engine/HTTP.pm @@ -113,12 +113,6 @@ sub run { $options ||= {}; - our $GOT_HUP; - local $GOT_HUP = 0; - - local $SIG{HUP} = sub { $GOT_HUP = 1; }; - local $SIG{CHLD} = 'IGNORE'; - # Setup restarter my $restarter; if ( $options->{restart} ) { @@ -135,7 +129,11 @@ sub run { my $regex = $options->{restart_regex}; my $one = _index( $dir, $regex ); RESTART: while (1) { - sleep $options->{restart_delay}; + sleep $options->{restart_delay} || 1; + + # check if our parent has died + exit if ( getppid == 1 ); + my $two = _index( $dir, $regex ); my $changes = _compare_index( $one, $two ); if (@$changes) { @@ -163,6 +161,12 @@ sub run { } } } + + our $GOT_HUP; + local $GOT_HUP = 0; + + local $SIG{HUP} = sub { $GOT_HUP = 1; }; + local $SIG{CHLD} = 'IGNORE'; # Handle requests