[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
wait -n shouldn't collect multiple processes
From: |
Ben Elliston |
Subject: |
wait -n shouldn't collect multiple processes |
Date: |
Sat, 23 Mar 2019 16:33:46 +1100 |
User-agent: |
NeoMutt/20170609 (1.8.3) |
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