Here's what the test looks like:
if (my $pid = fork) { eval 'use Test::More qw(no_plan)'; sleep 1;
# interact with server (child process)
# ...
kill TERM => $pid; my $kid; my $c = 0;
while (($kid = waitpid($pid, WNOHANG)) == 0) {
last if $c > 10; # really long because Devel::Cover is slooooow!
sleep 1;
$c++;
} if ($kid > 0) {
if ($?) {
fail("Child died with $?\n");
} else {
pass("Child exited");
}
} else {
fail("Child did not exit");
kill 9 => $pid;
}} else {
# run server process
}So, as you can see, I interact with the child process in a way to tickle the bug, then send it a shutdown signal, then wait for 10 seconds for it to terminate. Unfortunately, it's seeming like even 10 seconds is not enough sometimes.
Does anyone have a suggestion of how else to do this type of test? Is there some good way that I could figure out if the process is blocking indefinitely or just running the shutdown very slowly?
Thanks,
Kevin
