ftp.pm: Made Perl testsuite able to kill Windows processes
This commit is contained in:
parent
e3787e862f
commit
efa5488448
27
tests/ftp.pm
27
tests/ftp.pm
@ -111,6 +111,17 @@ sub killpid {
|
|||||||
if($tmp =~ /^(\d+)$/) {
|
if($tmp =~ /^(\d+)$/) {
|
||||||
my $pid = $1;
|
my $pid = $1;
|
||||||
if($pid > 0) {
|
if($pid > 0) {
|
||||||
|
if($^O eq "msys") {
|
||||||
|
my $filter = "-fi \"PID eq $pid\"";
|
||||||
|
my $result = `tasklist $filter 2>nul`;
|
||||||
|
if(index($result, "$pid") != -1) {
|
||||||
|
print("RUN: Process with pid $pid requested to quit\n")
|
||||||
|
if($verbose);
|
||||||
|
system("taskkill $filter >nul 2>&1");
|
||||||
|
push @signalled, $pid;
|
||||||
|
next; # it is a Windows PID
|
||||||
|
}
|
||||||
|
}
|
||||||
if(kill(0, $pid)) {
|
if(kill(0, $pid)) {
|
||||||
print("RUN: Process with pid $pid signalled to die\n")
|
print("RUN: Process with pid $pid signalled to die\n")
|
||||||
if($verbose);
|
if($verbose);
|
||||||
@ -134,6 +145,13 @@ sub killpid {
|
|||||||
while($twentieths--) {
|
while($twentieths--) {
|
||||||
for(my $i = scalar(@signalled) - 1; $i >= 0; $i--) {
|
for(my $i = scalar(@signalled) - 1; $i >= 0; $i--) {
|
||||||
my $pid = $signalled[$i];
|
my $pid = $signalled[$i];
|
||||||
|
if($^O eq "msys") {
|
||||||
|
my $filter = "-fi \"PID eq $pid\"";
|
||||||
|
my $result = `tasklist $filter 2>nul`;
|
||||||
|
if(index($result, "$pid") != -1) {
|
||||||
|
next; # the Windows PID still exists
|
||||||
|
}
|
||||||
|
}
|
||||||
if(!kill(0, $pid)) {
|
if(!kill(0, $pid)) {
|
||||||
print("RUN: Process with pid $pid gracefully died\n")
|
print("RUN: Process with pid $pid gracefully died\n")
|
||||||
if($verbose);
|
if($verbose);
|
||||||
@ -155,6 +173,15 @@ 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($^O eq "msys") {
|
||||||
|
my $filter = "-fi \"PID eq $pid\"";
|
||||||
|
my $result = `tasklist $filter 2>nul`;
|
||||||
|
if(index($result, "$pid") != -1) {
|
||||||
|
print("RUN: Process with pid $pid forced to quit\n")
|
||||||
|
if($verbose);
|
||||||
|
system("taskkill -f $filter >nul 2>&1");
|
||||||
|
}
|
||||||
|
}
|
||||||
# if possible reap its dead children
|
# if possible reap its dead children
|
||||||
waitpid($pid, &WNOHANG);
|
waitpid($pid, &WNOHANG);
|
||||||
push @reapchild, $pid;
|
push @reapchild, $pid;
|
||||||
|
Loading…
Reference in New Issue
Block a user