mirror of
https://github.com/curl/curl.git
synced 2026-08-25 00:43:34 +03:00
processhelp.pm: log taskkill pid info, add debug envs, enable in CI
To debug the Windows CI fails further. Acting on the suspicions that `taskkill` may sometimes be applied to the wrong process. - log task info, and task child info before calling `taskkill` on a PID. (on native Windows.) One of the calls needs PowerShell. - add env `CURL_TEST_NO_TASKKILL` to disable using `taskkill`. - add env `CURL_TEST_NO_TASKKILL_TREE` to use `taskkill` without `-t`, meaning to kill the process, but not child processes. - GHA/windows: disable `taskkill` calls, to see what happens. I'll revert or tweak this in a future commit depending on results. Ref: https://github.com/curl/curl/discussions/14854#discussioncomment-13062859 Ref: https://github.com/curl/curl/discussions/14854#discussioncomment-14913014 Closes #19421
This commit is contained in:
parent
c6f1b0ff49
commit
2701ac6a4d
3 changed files with 48 additions and 9 deletions
|
|
@ -169,10 +169,29 @@ sub pidterm {
|
|||
if($has_win32_process) {
|
||||
Win32::Process::KillProcess($pid, 0);
|
||||
} else {
|
||||
# https://ss64.com/nt/taskkill.html
|
||||
my $cmd = "taskkill -f -t -pid $pid >$dev_null 2>&1";
|
||||
print "Executing: '$cmd'\n";
|
||||
system($cmd);
|
||||
# https://ss64.com/nt/tasklist.html
|
||||
my $result = `tasklist -v -fo list -fi "PID eq $pid" 2>&1`;
|
||||
$result =~ s/\r//g;
|
||||
$result =~ s/\n/ | /g;
|
||||
print "Task info for $pid before taskkill: '$result'\n";
|
||||
|
||||
$result = `powershell -Command "Get-CimInstance -ClassName Win32_Process -Filter 'ParentProcessId=$pid' | Select ProcessId,ParentProcessId,Name,CommandLine"`;
|
||||
$result =~ s/\r//g;
|
||||
print "Task child processes for $pid before taskkill:\n";
|
||||
print "$result\n";
|
||||
|
||||
if(!$ENV{'CURL_TEST_NO_TASKKILL'}) {
|
||||
# https://ss64.com/nt/taskkill.html
|
||||
my $cmd;
|
||||
if($ENV{'CURL_TEST_NO_TASKKILL_TREE'}) {
|
||||
$cmd = "taskkill -f -pid $pid >$dev_null 2>&1";
|
||||
}
|
||||
else {
|
||||
$cmd = "taskkill -f -t -pid $pid >$dev_null 2>&1";
|
||||
}
|
||||
print "Executing: '$cmd'\n";
|
||||
system($cmd);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -198,10 +217,29 @@ sub pidkill {
|
|||
if($has_win32_process) {
|
||||
Win32::Process::KillProcess($pid, 0);
|
||||
} else {
|
||||
# https://ss64.com/nt/taskkill.html
|
||||
my $cmd = "taskkill -f -t -pid $pid >$dev_null 2>&1";
|
||||
print "Executing: '$cmd'\n";
|
||||
system($cmd);
|
||||
# https://ss64.com/nt/tasklist.html
|
||||
my $result = `tasklist -v -fo list -fi "PID eq $pid" 2>&1`;
|
||||
$result =~ s/\r//g;
|
||||
$result =~ s/\n/ | /g;
|
||||
print "Task info for $pid before taskkill: '$result'\n";
|
||||
|
||||
$result = `powershell -Command "Get-CimInstance -ClassName Win32_Process -Filter 'ParentProcessId=$pid' | Select ProcessId,ParentProcessId,Name,CommandLine"`;
|
||||
$result =~ s/\r//g;
|
||||
print "Task child processes for $pid before taskkill:\n";
|
||||
print "$result\n";
|
||||
|
||||
if(!$ENV{'CURL_TEST_NO_TASKKILL'}) {
|
||||
# https://ss64.com/nt/taskkill.html
|
||||
my $cmd;
|
||||
if($ENV{'CURL_TEST_NO_TASKKILL_TREE'}) {
|
||||
$cmd = "taskkill -f -pid $pid >$dev_null 2>&1";
|
||||
}
|
||||
else {
|
||||
$cmd = "taskkill -f -t -pid $pid >$dev_null 2>&1";
|
||||
}
|
||||
print "Executing: '$cmd'\n";
|
||||
system($cmd);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue