diff --git a/tests/checks/jobs.fish b/tests/checks/jobs.fish index 3b591d0a7..08fbb2223 100644 --- a/tests/checks/jobs.fish +++ b/tests/checks/jobs.fish @@ -1,22 +1,5 @@ #RUN: %fish %s -# Ensure there's no zombies before we start, otherwise the tests will mysteriously fail. -set -l zombies_among_us -if not contains (uname) SunOS - set zombies_among_us (ps -o stat | string match 'Z*' | count) -else - # Solaris' ps is awkward, I don't know if this actually works - set zombies_among_us (ps -o s | string match 'Z*' | count) -end - -[ "$zombies_among_us" -eq "0" ] -or begin - echo "Found existing zombie processes. Clean up zombies before running this test." - exit 1 -end -echo "All clear of zombies." -# CHECK: All clear of zombies. - # Verify zombies are not left by disown (#7183, #5342) # Do this first to avoid colliding with the other disowned processes below, which may # still be running at the end of the script @@ -28,13 +11,15 @@ sleep 0.1 #CHECK: Trigger process reaping # The initial approach here was to kill the PID of the sleep process, which should # be gone by the time we get here. Unfortunately, kill from procps on pre-2016 distributions -# does not print an error for non-existent PIDs, so instead look for zombies in this session -# (there should be none). +# does not print an error for non-existent PIDs, so instead look for zombies in this session. +# There could already be zombies from previous tests run in this session or a test could be run +# simultaneously that causes a zombie to spawn, so limit the output only to processes started by +# this fish instance. if not contains (uname) SunOS - ps -o stat | string match 'Z*' + ps -o ppid,stat else - ps -o s | string match 'Z*' -end + ps -o ppid,s +end | string match -e $fish_pid | string match 'Z*' # Verify disown can be used with last_pid, even if it is separate from the pgroup. # This should silently succeed.