[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: Tue, 28 Mar 2017 18:03:55 +0300

> From: address@hidden
> Date: Mon, 27 Mar 2017 23:40:19 -0600
> Cc: address@hidden, address@hidden
> Eli Zaretskii <address@hidden> wrote:
> > > Gawk will exit FATAL. It should all work ok.
> >
> > I'm not sure it will, but I don't think I see the whole picture yet.
> >
> > Shouldn't we emulate an abnormal exit, as in "crash"?  EXIT_FAIL is
> > not it, it just means "some error".
> "Crash" to me means core dump. SIGPIPE doesn't cause a core dump

Since Windows doesn't have core files, there's no real difference in
behavior here.

> it
> just causes exit with the death-by-signal bit set and the signal number
> in the status. The shells turn that into 128 + signal number.

An abnormal exit on Windows produces a distinct bit pattern in the
value of exit code, just like it does on Unix (the value is, of
course, different).  Try running on Windows a program that crashes
with the equivalent of SIGSEGV, and then look at ERRORLEVEL in the
shell (display it in hex to make sense of its value), and you will
clearly see that.

By contrast, EXIT_FAILURE is just 1, an exit status that many programs
produce under normal conditions to indicate that something unusual
happened.  E.g., Grep exits with status 1 to indicate that it didn't
find any matches -- a far cry from termination due to a fatal signal.

So I'm asking whether we should produce on Windows an exit status that
indicates abnormal termination by a fatal exception.

> For non-POSIX we could use a different signal, but we'd have to choose
> one that's pretty universal. SIGHUP might be the best bet.

SIGHUP is not defined on Windows, so this won't work.  And it won't
affect the exit status, unlike on Posix platforms, even if it existed.

> > > If you want a tarball let me know
> >
> > Yes, please.  And also a script that could be used to test this
> > situation.
> URL sent.
> Script is what started the discussion
>       yes | gawk '{ print; fflush(stdout) }' | head

Thanks, will look into this soon.

reply via email to

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