[Top][All Lists]

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

Re: [bug-gawk] Behavior of fflush with SIGPIPE on stdout [PATCH]

From: FERRIEUX Alexandre - IMT/OLN
Subject: Re: [bug-gawk] Behavior of fflush with SIGPIPE on stdout [PATCH]
Date: Sat, 25 Mar 2017 14:50:19 +0100
User-agent: Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111113 Thunderbird/8.0

On 25/03/2017 14:41, Andrew J. Schorr wrote:
On Sat, Mar 25, 2017 at 11:49:31AM +0100, FERRIEUX Alexandre - IMT/OLN wrote:
 On 25/03/2017 01:16, Andrew J. Schorr wrote:
 >Why is it exiting successfully
 >when it catches a SIGPIPE? As far as I can tell, that's not normal.

 Agreed. And while you're at it, a full emulation of
 exiting-with-default-SIGPIPE-handler would be even cleaner: exit
 status should end up as 141 = 128+EPIPE.

        cat /etc/services | head -1 ; echo $?
        # /etc/services:

Hmmm. I'm not sure, but I suspect this may be platform-specific.
Actually, testing on Cygwin, I don't get any error at all:

$ uname -a
CYGWIN_NT-10.0 ti47 2.5.0(0.297/5/3) 2016-04-11 09:58 x86_64 Cygwin

$ false | head -1; echo $?

$ cat /etc/services | head -1 ; echo $?
# Copyright (c) 1993-2004 Microsoft Corp.

I don't know why that's the case.

You forgot "set -o pipefail".
Here is a variant that doesn't need it:

  (cat /etc/services;echo $?>&2) | head -1
  # /etc/services:

reply via email to

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