Change 34316 by [EMAIL PROTECTED] on 2008/09/08 02:41:04
Make sure the watchdog requeues itself when sleep() wakes up early
(such as when an alarm fires). Also, bail out with SIGTERM rather
than SIGKILL on VMS since the latter kills the shell from which
Perl was started.
Affected files ...
... //depot/perl/t/test.pl#88 edit
Differences ...
==== //depot/perl/t/test.pl#88 (text) ====
Index: perl/t/test.pl
--- perl/t/test.pl#87~34179~ 2008-08-07 03:12:09.000000000 -0700
+++ perl/t/test.pl 2008-09-07 19:41:04.000000000 -0700
@@ -843,10 +843,11 @@
local $SIG{'__WARN__'} = sub {
_diag("Watchdog warning: $_[0]");
};
+ my $sig = $^O eq 'VMS' ? 'TERM' : 'KILL';
$watchdog = system(1, which_perl(), '-e',
"sleep($timeout);" .
"warn('#
$timeout_msg\n');" .
- "kill('KILL',
$pid_to_kill);");
+ "kill($sig,
$pid_to_kill);");
};
if ($@ || ($watchdog <= 0)) {
_diag('Failed to start watchdog');
@@ -908,13 +909,19 @@
eval { require POSIX; };
# Execute the timeout
- sleep($timeout);
+ my $time_elapsed = 0;
+ my $time_left = $timeout;
+ while ($time_elapsed < $timeout) {
+ $time_elapsed += sleep($time_left);
+ $time_left = $timeout - $time_elapsed;
+ }
# Kill the parent (and ourself)
select(STDERR); $| = 1;
_diag($timeout_msg);
POSIX::_exit(1) if (defined(&POSIX::_exit));
- kill('KILL', $pid_to_kill);
+ my $sig = $^O eq 'VMS' ? 'TERM' : 'KILL';
+ kill($sig, $pid_to_kill);
})->detach();
return;
}
@@ -929,7 +936,8 @@
select(STDERR); $| = 1;
_diag($timeout_msg);
POSIX::_exit(1) if (defined(&POSIX::_exit));
- kill('KILL', $pid_to_kill);
+ my $sig = $^O eq 'VMS' ? 'TERM' : 'KILL';
+ kill($sig, $pid_to_kill);
};
}
}
End of Patch.