bug-bash
[Top][All Lists]
Advanced

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

Re: Parallelism a la make -j <n> / GNU parallel


From: Chet Ramey
Subject: Re: Parallelism a la make -j <n> / GNU parallel
Date: Mon, 07 May 2012 08:56:54 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:11.0) Gecko/20120327 Thunderbird/11.0.1

On 5/5/12 11:25 PM, John Kearney wrote:

> Is there actually a guarantee that there will be 1 SIGCHLD for every
> exited process.

The manual page says, under JOB CONTROL:

Any trap on SIGCHLD is executed for each child that exits.

> Isn't it actually a race condition?

No.  waitpid() returns once for each child that exits.  That's why you
loop calling waitpid() when you get a SIGCHLD.  It keeps returning PIDs
until there are no more unreaped children, then it returns -1.

Chet

-- 
``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]