[Top][All Lists]

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

Re: Strange behaviour on 'read' from a pipe

From: Chet Ramey
Subject: Re: Strange behaviour on 'read' from a pipe
Date: Sat, 31 Mar 2012 21:16:20 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

On 3/31/12 9:19 AM, Lluís Batlle i Rossell wrote:
> Hello,
> I have this script, that I've found to never write "DONE" in my systems, with
> bash 4.0, 4.1, 4.2.. until 4.2-p20, my last test.
> However, in irc some people told me it prints DONE for them. If I run the 
> script with
> bash under 'strace -f', it also prints DONE.

It looks like a simple race condition.  I suspect that the scheduler
arranges things so that the child process ends up exiting between the
open and the read, but I don't have any real evidence to back it up.
(Like you, my Mac OS X system prints `DONE'.)

You might want to try using exec to open the FIFO in the parent process
rather than trying to open it on each read.

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

reply via email to

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