[Top][All Lists]

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

Re: Strange behaviour on 'read' from a pipe

From: Lluís Batlle i Rossell
Subject: Re: Strange behaviour on 'read' from a pipe
Date: Sun, 1 Apr 2012 10:52:30 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

On Sat, Mar 31, 2012 at 09:16:20PM -0400, Chet Ramey wrote:
> 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.

Yes, I know I can work around it, but I meant that the race of the parent
getting SIGCHLD in the read call did not bring any useful outcome.

For me, useful outcomes could be:
- read nothing, and unblock with error
- keep on reading the same fd

But it does not do any of those.

Thank you,

reply via email to

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