bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: CHLD traps run at the same time


From: Chet Ramey
Subject: Re: CHLD traps run at the same time
Date: Wed, 14 Jan 2015 10:19:02 -0500
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.3.0

On 1/14/15 6:01 AM, Øyvind 'bolt' Hvidsten wrote:
> I'm responsible for a couple of scripts at work, which have used a trap on
> CHLD to do some naive parallelisation, starting a new child process when an
> existing one ends.
> 
> However, when run under bash 4.3.30, all CHLD traps run at the same time,
> so my script runs in chunks, rather than keeping a given amount of
> processes running at all times. I've been told I can rewrite it using wait
> -n instead, but I'm wondering if this is classified as a bug, or if it's
> intended to be that way going forwards.

It's not a bug.  The only guarantee is that the CHLD trap gets run once for
each child bash reaps.

Bash gets SIGCHLD, reaps as many terminated child processes as it can, then
runs the CHLD trap once for each terminated child when it's no longer in a
signal handler context.  I don't have any plans to change this.

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]