Skip to content
Permalink
Browse files
MDEV-29023 waitpid() cleanup
The case for "Unknown process $ret_pid exited" is never known to be
valid. Such state is not documented for waitpid().
  • Loading branch information
midenok committed Jul 18, 2022
1 parent 1d307ed commit 7ca5c7d
Showing 1 changed file with 7 additions and 5 deletions.
@@ -661,12 +661,14 @@ sub main {
foreach my $pid (keys %children)
{
my $ret_pid= waitpid($pid, 0);
if ($ret_pid != $pid){
mtr_report("Unknown process $ret_pid exited");
}
else {
delete $children{$ret_pid};
if ($ret_pid == -1) {
# Child was automatically reaped. Probably not possible
# unless you $SIG{CHLD}= 'IGNORE'
mtr_report("Child ${pid} was automatically reaped (this should never happend)");
} elsif ($ret_pid != $pid) {
confess("Unexpected PID ${ret_pid} instead of expected ${pid}");
}
delete $children{$ret_pid};
}
}

0 comments on commit 7ca5c7d

Please sign in to comment.