X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-0.7 required=5.0 tests=BAYES_20,SPF_PASS X-Spam-Check-By: sourceware.org Date: Thu, 30 Jul 2009 13:09:21 +0000 (UTC) From: Eric Blake To: David Antliff Cc: cygwin AT cygwin DOT com Message-ID: <770992004.6687041248959361064.JavaMail.root@sz0059a.emeryville.ca.mail.comcast.net> In-Reply-To: Subject: Re: bash pipeline exit code - possible race condition? MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com > >>I've noticed a strange problem with bash pipelines in Cygwin that > >>might indicate some sort of race condition. I cannot reproduce the > >>problem on a Linux system, but it seems easy to reproduce in > Cygwin. > > > > This doesn't appear to be a cygwin problem. =C2=A0I get occasional > errors > > on linux as well. >=20 > I tried to reproduce on Linux but without success - did you simply > run > my script or perhaps something else? Do you see error "141" as well? Status 141 is from SIGPIPE. Basically, it happens when the read end of the pipe exits before the writer. It is not specific to cygwin, but may occur more frequently on cygwin since cygwin has different scheduling than Linux. It is not an error in the OS - if you are going to worry about the exit status of all processes in a pipeline, then you must be prepared to deal with the earlier processes ending abruptly because the later processes aren't interested in any more data. There's nothing we can do to change this race, and complaining to the bash folks won't change it either. About the only thing you could do by complaining to the bash folks is to get another shell option that ignores sigpipe failures when you are paying attention to all statuses within a pipeline, rather than the normal behavior of just the last status. --=20 Eric Blake -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple