mirror of
https://github.com/moparisthebest/curl
synced 2024-08-13 17:03:50 -04:00
Reap processes dead children ASAP without blocking
This commit is contained in:
parent
1cfa52b67d
commit
bdd3763980
10
tests/ftp.pm
10
tests/ftp.pm
@ -63,7 +63,7 @@ sub processexists {
|
|||||||
# get rid of the certainly invalid pidfile
|
# get rid of the certainly invalid pidfile
|
||||||
unlink($pidfile) if($pid == pidfromfile($pidfile));
|
unlink($pidfile) if($pid == pidfromfile($pidfile));
|
||||||
# reap its dead children, if not done yet
|
# reap its dead children, if not done yet
|
||||||
# waitpid($pid, &WNOHANG);
|
waitpid($pid, &WNOHANG);
|
||||||
# negative return value means dead process
|
# negative return value means dead process
|
||||||
return -$pid;
|
return -$pid;
|
||||||
}
|
}
|
||||||
@ -112,6 +112,8 @@ sub killpid {
|
|||||||
else {
|
else {
|
||||||
print("RUN: Process with pid $pid already dead\n")
|
print("RUN: Process with pid $pid already dead\n")
|
||||||
if($verbose);
|
if($verbose);
|
||||||
|
# if possible reap its dead children
|
||||||
|
waitpid($pid, &WNOHANG);
|
||||||
push @reapchild, $pid;
|
push @reapchild, $pid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,6 +130,8 @@ sub killpid {
|
|||||||
print("RUN: Process with pid $pid gracefully died\n")
|
print("RUN: Process with pid $pid gracefully died\n")
|
||||||
if($verbose);
|
if($verbose);
|
||||||
splice @signalled, $i, 1;
|
splice @signalled, $i, 1;
|
||||||
|
# if possible reap its dead children
|
||||||
|
waitpid($pid, &WNOHANG);
|
||||||
push @reapchild, $pid;
|
push @reapchild, $pid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,12 +147,14 @@ sub killpid {
|
|||||||
print("RUN: Process with pid $pid forced to die with SIGKILL\n")
|
print("RUN: Process with pid $pid forced to die with SIGKILL\n")
|
||||||
if($verbose);
|
if($verbose);
|
||||||
kill("KILL", $pid);
|
kill("KILL", $pid);
|
||||||
|
# if possible reap its dead children
|
||||||
|
waitpid($pid, &WNOHANG);
|
||||||
push @reapchild, $pid;
|
push @reapchild, $pid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Reap processes dead children.
|
# Reap processes dead children for sure.
|
||||||
if(defined(@reapchild)) {
|
if(defined(@reapchild)) {
|
||||||
foreach my $pid (@reapchild) {
|
foreach my $pid (@reapchild) {
|
||||||
if($pid > 0) {
|
if($pid > 0) {
|
||||||
|
Loading…
Reference in New Issue
Block a user