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] Donesleep 10
[2] Done
On Sat, Mar 23, 2019 at 11:48:33AM -0400, Chet Ramey wrote:
> What's your goal here? If you want to associate an exit status with
> a process, you're going to have to save $! and wait for each process
> in turn.
My goal is to run a small process pool where upon one process
completes, another one
On Sun, Mar 24, 2019 at 11:29:41AM -0400, Chet Ramey wrote:
> > My goal is to run a small process pool where upon one process
> > completes, another one is started immediately. If I start (say) 10
> > processes and then wait on the first, I may have chosen the longest
> > running process.
>
> OK.
On Mon, Mar 25, 2019 at 10:49:32AM -0400, Chet Ramey wrote:
> This demonstrates that, despite what I said earlier, `wait -n' reaps
> one process at a time and returns its exit status.
Thanks a lot. Can I suggest that a small tweak be made to the
documentation to make this a bit clearer?
Cheers,
On Mon, Mar 25, 2019 at 04:53:02PM -0400, Chet Ramey wrote:
> "wait waits for any job to terminate and returns its exit status"
>
> Doesn't that imply a single job?
Not as clearly as saying "wait waits for a single job to terminate"
:-) I guess I'm thinking that an exxplanation about the inter