[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: wait -n shouldn't collect multiple processes
From: |
Chet Ramey |
Subject: |
Re: wait -n shouldn't collect multiple processes |
Date: |
Sun, 24 Mar 2019 11:29:41 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 |
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 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. This sounds like a candidate for a SIGCHLD trap. You're not interested
in a particular process's exit status, so you can keep a count of running
processes and start new ones out of a trap handler.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
signature.asc
Description: OpenPGP digital signature