Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Strange behaviour on 'read' from a pipe

Received: by 10.68.232.169 with SMTP id tp9mr3110575pbc.6.1333243003822;
        Sat, 31 Mar 2012 18:16:43 -0700 (PDT)
Path: r9ni4637pbh.0!nntp.google.com!news2.google.com!news1.google.com!news.glorb.com!usenet.stanford.edu!not-for-mail
From: Chet Ramey <chet.ra...@case.edu>
Newsgroups: gnu.bash.bug
Subject: Re: Strange behaviour on 'read' from a pipe
Date: Sat, 31 Mar 2012 21:16:20 -0400
Organization: ITS, Case Western Reserve University
Lines: 22
Approved: bug-b...@gnu.org
Message-ID: <mailman.252.1333243002.20052.bug-bash@gnu.org>
References: <20120331131938.GM3029@vicerveza.homeunix.net>
Reply-To: chet.ra...@case.edu
NNTP-Posting-Host: lists.gnu.org
Mime-Version: 1.0
X-Trace: usenet.stanford.edu 1333243003 18914 208.118.235.17 (1 Apr 2012 01:16:43 GMT)
X-Complaints-To: action@cs.stanford.edu
Cc: bug-b...@gnu.org, chet.ra...@case.edu
To: =?ISO-8859-1?Q?Llu=EDs_Batlle_i_Rossell?= <vi...@viric.name>
Envelope-to: bug-b...@gnu.org
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6;
	rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2
In-Reply-To: <20120331131938.GM3029@vicerveza.homeunix.net>
X-Enigmail-Version: 1.4
X-Junkmail-Whitelist: YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system: by eggs.gnu.org: Genre and OS details not
	recognized.
X-Received-From: 129.22.105.36
X-BeenThere: bug-b...@gnu.org
X-Mailman-Version: 2.1.14
Precedence: list
List-Id: Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe: <https://lists.gnu.org/mailman/options/bug-bash>,
	<mailto:bug-bash-requ...@gnu.org?subject=unsubscribe>
List-Archive: <http://lists.gnu.org/archive/html/bug-bash>
List-Post: <mailto:bug-b...@gnu.org>
List-Help: <mailto:bug-bash-requ...@gnu.org?subject=help>
List-Subscribe: <https://lists.gnu.org/mailman/listinfo/bug-bash>,
	<mailto:bug-bash-requ...@gnu.org?subject=subscribe>
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit

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    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/