Re: wait -n shouldn't collect multiple processes

2019-03-26 Thread Robert Elz
Date:Tue, 26 Mar 2019 10:55:53 +0100 From:Andreas Schwab Message-ID: | Even better, IMHO: "wait waits for the next job to terminate" Something should allow for there being no waiting involved at all if some job has already terminated but has not been waited for.

Re: wait -n shouldn't collect multiple processes

2019-03-26 Thread Andreas Schwab
On Mär 26 2019, Ben Elliston wrote: > 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" Even better,

Re: wait -n shouldn't collect multiple processes

2019-03-25 Thread Ben Elliston
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

Re: wait -n shouldn't collect multiple processes

2019-03-25 Thread Chet Ramey
On 3/25/19 4:47 PM, Ben Elliston wrote: > 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

Re: wait -n shouldn't collect multiple processes

2019-03-25 Thread Ben Elliston
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,

Re: wait -n shouldn't collect multiple processes

2019-03-25 Thread Chet Ramey
On 3/25/19 4:05 PM, Robert Elz wrote: > Date:Mon, 25 Mar 2019 10:49:32 -0400 > From:Chet Ramey > Message-ID: <9c536452-4f4e-b309-7a99-e85235364...@case.edu> > > Great to see that revised description of how it works, that makes > much more sense. I also should have

Re: wait -n shouldn't collect multiple processes

2019-03-25 Thread Robert Elz
Date:Mon, 25 Mar 2019 10:49:32 -0400 From:Chet Ramey Message-ID: <9c536452-4f4e-b309-7a99-e85235364...@case.edu> Great to see that revised description of how it works, that makes much more sense. I also should have tested it. | `wait -n' is only useful in

Re: wait -n shouldn't collect multiple processes

2019-03-25 Thread Chet Ramey
On 3/23/19 1:33 AM, Ben Elliston wrote: > 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]

Re: wait -n shouldn't collect multiple processes

2019-03-24 Thread Ben Elliston
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. > >

Re: wait -n shouldn't collect multiple processes

2019-03-24 Thread Chet Ramey
On 3/23/19 12:31 PM, Robert Elz wrote: > | If you want to associated an exit status with a process, changing wait -n > | wouldn't make a difference. > > It does when you add the "-p var" option, which returns the pid of the > process (job) that exited as $var If I add that, I might change

Re: wait -n shouldn't collect multiple processes

2019-03-24 Thread Chet Ramey
On 3/23/19 5:15 PM, Ben Elliston wrote: > 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

Re: wait -n shouldn't collect multiple processes

2019-03-23 Thread Ben Elliston
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

Re: wait -n shouldn't collect multiple processes

2019-03-23 Thread Robert Elz
I should have added in my previous reply, that using an interactive shell to test this is useless, as even if wait -n only returned one process, before the next command prompt any other processes that have exited will be waited upon and cleaned up anyway (and in that case, jobs type output is

Re: wait -n shouldn't collect multiple processes

2019-03-23 Thread Robert Elz
Date:Sat, 23 Mar 2019 11:48:33 -0400 From:Chet Ramey Message-ID: <36545673-c287-6d8a-5e99-004ce9c6b...@case.edu> | Yes. It waits for the next process to exit and then reaps all exited | children. That doesn't sound very useful. Our version (the NetBSD sh)

Re: wait -n shouldn't collect multiple processes

2019-03-23 Thread Chet Ramey
On 3/23/19 1:33 AM, Ben Elliston wrote: > In bash 4.4.19, wait -n will collect the exit status of multiple > processes if there are any -- not just one: Yes. It waits for the next process to exit and then reaps all exited children. > > bje@bapbop:~$ sleep 10 & sleep 10 & sleep 10 & sleep 10 & >

wait -n shouldn't collect multiple processes

2019-03-23 Thread Ben Elliston
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