[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: Eli Zaretskii
Subject: Re: [bug-gawk] Behavior of fflush with SIGPIPE on stdout [PATCH]
Date: Sat, 25 Mar 2017 22:34:11 +0300

> Date: Sat, 25 Mar 2017 11:13:40 -0400
> From: "Andrew J. Schorr" <address@hidden>
> Cc: address@hidden
> On Sat, Mar 25, 2017 at 03:48:27PM +0100, FERRIEUX Alexandre - IMT/OLN wrote:
> > In any case, consider the timeline: old gawk gave a 141 due to the
> > absence of any handler; new gawk (for reasons not entirely clear to
> > me) decides that default handlers are not good enough and intercepts
> > SIGPIPE. It is trivial to make this transparent by writing
> > "exit(128+EPIPE)". What's the point of sticking to a dumb exit(0) or
> > exit(1) ?
> My concern is behavior on the various non-POSIX platforms.  From the docs: 
> "The
> currently supported [non-POSIX] systems are MS-Windows using MSYS, MinGW, and
> Cygwin, and both Vax/VMS and OpenVMS." It looks like Cygwin is OK, but I don't
> know about the others.

Cygwin isn't Windows, it's a Posix-compliant environment on top of
Windows.  It uses a large shared library to provide that.

The native Windows port of Gawk is the one using MinGW.

> Is 128+EPIPE a cross-platform standard?

No, of course not.  It's Posix-only.

> As to why we are trapping SIGPIPE, that's a bit more complicated. The original
> comment in main.c about this says:
>         /*
>          * Ignore SIGPIPE so that writes to pipes that fail don't
>          * kill the process but instead return -1 and set errno.
>          * That lets us print a fatal message instead of dieing suddenly.
>          *
>          * Note that this requires ignoring EPIPE when writing and
>          * flushing stdout/stderr in other parts of the program. E.g.,
>          *
>          *      gawk 'BEGIN { print "hi" }' | exit
>          *
>          * should not give us "broken pipe" messages --- mainly because
>          * it did not do so in the past and people would complain.
>          */
> Apparently, people will still complain. :-)

FWIW, I don't see a problem here.  It's perfectly valid for a program
to catch SIGPIPE, and a program that does should not be expected to
exit with 128+EPIPE, AFAIU.

reply via email to

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