Re: [PATCH v3 08/19] write_or_die: raise SIGPIPE when we get EPIPE
- From
Jeff King <peff@peff.net>
- Date
- Feb 20, 2013, 22:12 UTC
- Message-ID
- <20130220221248.GC817@sigill.intra.peff.net>
- In-Reply-To
- <20130220220637.GC24236@google.com>
On Wed, Feb 20, 2013 at 02:06:37PM -0800, Jonathan Nieder wrote:
Show 8 quoted lines
> > I don't mind adding a "BUG: " message like you described, but we should > > still try to exit(141) as the backup, since that is the shell-equivalent > > code to the SIGPIPE signal death. > > If you want. :) > > I think caring about graceful degradation of behavior in the case of > an assertion failure is overengineering, but it's mostly harmless.
I am more concerned that the assertion is not "oops, another thread is doing something crazy, and it is a bug", but rather that there is some weird platform where SIG_DFL does not kill the program under SIGPIPE. That seems pretty crazy, though. I think I'd squash in something like this:
diff --git a/write_or_die.c b/write_or_die.c index b50f99a..abb64db 100644 --- a/write_or_die.c +++ b/write_or_die.c @@ -5,7 +5,9 @@ static void check_pipe(int err) if (err == EPIPE) { signal(SIGPIPE, SIG_DFL); raise(SIGPIPE); + /* Should never happen, but just in case... */ + error("BUG: SIGPIPE on SIG_DFL handler did not kill us."); exit(141); } } which more directly reports the assertion that failed, and degrades reasonably gracefully. Yeah, it's probably overengineering, but it's easy enough to do. -Peff