[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
[PATCH] [perl #49073] SIGTERM not terminating child process
Jerry D. Hedden reported:
> This shows that the SIGTERM to the child process is knocking
> it out of its sleep call, but is not terminating the process.
Jarkko Hietaniemi replied:
> I'm not saying that this shouldn't be made to work in Time::HiRes,
> what I am saying is that four different UNIXes (running mostly
> 5.8.8, one running 5.8.4) do not exhibit this behaviour, so I'm
> thinking something might be funny in Cygwin.
Reini Urban wrote:
> I can confirm this failing SIGTERM cygwin behaviour
> but didn't dig into a fix yet.
Attached is a workaround for t/HiRes.t to at least keep the
Time::HiRes test from reporting failures until the underlying
SIGTERM/sleep bug is fixed.
The workaround is to split the child's sleep in two. When the
parent sends SIGTERM, either the child will just die (basic case)
or will fall into a second short sleep (this is the workaround).
In the later case, the parent will then terminate, the child
will wake up, see that the parent has exited and will gracefully
exit as well.
--- perl-current/ext/Time/HiRes/t/HiRes.t
+++ perl-current/ext/Time/HiRes/t/HiRes.t
@@ -79,11 +79,14 @@
if ($timer_pid == 0) { # We are the kid, set up the timer.
my $ppid = getppid();
print "# I am the timer process $$, sleeping for $waitfor seconds...\n";
- sleep($waitfor);
- warn "\n$0: overall time allowed for tests (${waitfor}s) exceeded!\n";
- print "# Terminating main process $ppid...\n";
- kill('TERM', $ppid);
- print "# This is the timer process $$, over and out.\n";
+ sleep($waitfor - 2); # Workaround for perlbug #49073
+ sleep(2); # Wait for parent to exit
+ if (kill(0, $ppid)) { # Check if parent still exists
+ warn "\n$0: overall time allowed for tests (${waitfor}s) exceeded!\n";
+ print "# Terminating main process $ppid...\n";
+ kill('TERM', $ppid);
+ print "# This is the timer process $$, over and out.\n";
+ }
exit(0);
} else {
print "# The timer process $timer_pid launched, continuing testing...\n";
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]