[Catalyst-commits] r9904 -
Catalyst-Devel/1.00/branches/improved-restarter/lib/Catalyst
autarch at dev.catalyst.perl.org
autarch at dev.catalyst.perl.org
Mon Apr 27 21:10:00 GMT 2009
Author: autarch
Date: 2009-04-27 22:10:00 +0100 (Mon, 27 Apr 2009)
New Revision: 9904
Modified:
Catalyst-Devel/1.00/branches/improved-restarter/lib/Catalyst/Restarter.pm
Log:
Move killing the child into its own method and add a Win32-specific hack
Modified: Catalyst-Devel/1.00/branches/improved-restarter/lib/Catalyst/Restarter.pm
===================================================================
--- Catalyst-Devel/1.00/branches/improved-restarter/lib/Catalyst/Restarter.pm 2009-04-27 18:44:05 UTC (rev 9903)
+++ Catalyst-Devel/1.00/branches/improved-restarter/lib/Catalyst/Restarter.pm 2009-04-27 21:10:00 UTC (rev 9904)
@@ -70,10 +70,7 @@
print STDERR "\n";
print STDERR "Attempting to restart the server\n\n";
- if ( $self->_child ) {
- kill 2, $self->_child
- or die "Cannot send INT to child (" . $self->_child . "): $!";
- }
+ $self->_kill_child;
$self->_fork_and_start;
@@ -81,14 +78,28 @@
}
}
-sub DEMOLISH {
+sub _kill_child {
my $self = shift;
- if ( $self->_child ) {
- kill 2, $self->_child;
+ return unless $self->_child;
+
+ return unless kill 0, $self->_child;
+
+ local $SIG{CHLD} = 'IGNORE';
+ unless ( kill 'INT', $self->_child ) {
+ # The kill 0 thing does not work on Windows, but the restarter
+ # seems to work fine on Windows with this hack.
+ return if $^O eq 'MSWin32';
+ die "Cannot send INT signal to ", $self->_child, ": $!";
}
}
+sub DEMOLISH {
+ my $self = shift;
+
+ $self->_kill_child;
+}
+
__PACKAGE__->meta->make_immutable;
1;
More information about the Catalyst-commits
mailing list