In bash 4.4.19, wait -n will collect the exit status of multiple
processes if there are any -- not just one:

bje@bapbop:~$ sleep 10 & sleep 10 & sleep 10 & sleep 10 &
[1] 13296
[2] 13297
[3] 13298
[4] 13299
bje@bapbop:~$ wait -n
[1]   Done                    sleep 10
[2]   Done                    sleep 10
[3]-  Done                    sleep 10
[4]+  Done                    sleep 10

This makes it impossible to wait for the completion of any process and
then individually collect the exit status of each command. I think
wait -n should be guaranteed to only return one of the available
(terminated) processes. If there are multiple, they can be collected
by calling wait -n multiple times or calling wait without '-n'.

Ben

Reply via email to