[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wait -n ignores invalid pids when valid pids are listed
From: |
Beer, Mathis |
Subject: |
wait -n ignores invalid pids when valid pids are listed |
Date: |
Tue, 27 Apr 2021 05:57:40 +0000 |
Given a background process that has exited before the script got to wait -n:
function foo() { return 1; }
foo & FOO_PID=$!
function bar() { sleep 1; }
bar & BAR_PID=$!
sleep 0.1
# should exit with 127 since FOO_PID is non-existent now
wait -n $FOO_PID $BAR_PID
Then wait -n will wait on BAR_PID to exit, despite the fact that FOO_PID is
invalid. (Tested with 5.0.17.)
Shouldn't it immediately exit with 127, as the docs suggest, since one id
specifies a non-existent process?
The way it currently works makes it hard to make a script that waits for one
of a set of background processes to exit (ie. that fails if one of a set of
background processes fails), since any error that happens before the script
reaches the wait will simply be ignored.
- wait -n ignores invalid pids when valid pids are listed,
Beer, Mathis <=