Skip to content

Commit 064bcf1

Browse files
committed
(maint) Handle Cygwin 3
In Cygwin 3, `ps -efW` returns the Cygwin PID which cannot be passed to taskkill, so this test had no chance of cleaning up correctly on Windows 11. Updated to use WMI instead, as is done in pxp-agent.
1 parent 62b1f1b commit 064bcf1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

acceptance/tests/resource/exec/should_run_bad_command.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ def stop_sleep_process(targets, accept_no_pid_found = false)
2727
when /osx/
2828
command = "ps -e -o pid,comm | grep sleep | sed 's/^[^0-9]*//g' | cut -d\\ -f1"
2929
when /win/
30-
command = "ps -efW | grep PING | sed 's/^[^0-9]*[0-9]*[^0-9]*//g' | cut -d ' ' -f1"
30+
command = "cmd.exe /C WMIC path win32_process WHERE Name=\\\"PING.EXE\\\" get ProcessId | egrep -o '[0-9]+\\s*$'"
3131
else
3232
command = "ps -ef | grep 'bin/sleep ' | grep -v 'grep' | grep -v 'true' | sed 's/^[^0-9]*//g' | cut -d\\ -f1"
3333
end
3434

3535
# A failed test may leave an orphaned sleep process, handle multiple matches.
3636
pids = nil
37-
on(target, command) do |output|
37+
on(target, command, accept_all_exit_codes: accept_no_pid_found) do |output|
3838
pids = output.stdout.chomp.split
3939
if pids.empty? && !accept_no_pid_found
4040
raise("Did not find a pid for a sleep process on #{target}")

0 commit comments

Comments
 (0)