bug-bash
[Top][All Lists]
Advanced

[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 11:58:16 +0200
User-agent: Mutt/1.5.20 (2009-06-14)

On Sun, Apr 01, 2012 at 11:53:12AM +0200, Andreas Schwab wrote:
> Chet Ramey <address@hidden> writes:
> 
> > 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.
> 
> Note that the opening of the pipe as part of the redirection in the
> parent blocks until there is a writer, ie. until the child opens the
> pipe.  Can this open call return EINTR?

Ah, maybe this is the source trouble. EINTR in open, instead of read.

But in this case, even a C program could not be protected against this race
other than blocking signals before opening the descriptor.

Maybe someone else knows better.



reply via email to

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