diff options
author | Jeff King <peff@peff.net> | 2013-02-20 15:01:36 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-02-20 13:42:21 -0800 |
commit | 756e676ca011083dd15264ec29e281c47297ae40 (patch) | |
tree | 9e7668b6a9bfb78c2fdb671d325976558d18a874 /pkt-line.c | |
parent | 090fd4fe24b9da9d912aa5856f4cd32d157924c6 (diff) | |
download | git-756e676ca011083dd15264ec29e281c47297ae40.tar.gz |
write_or_die: raise SIGPIPE when we get EPIPE
The write_or_die function will always die on an error,
including EPIPE. However, it currently treats EPIPE
specially by suppressing any error message, and by exiting
with exit code 0.
Suppressing the error message makes some sense; a pipe death
may just be a sign that the other side is not interested in
what we have to say. However, exiting with a successful
error code is not a good idea, as write_or_die is frequently
used in cases where we want to be careful about having
written all of the output, and we may need to signal to our
caller that we have done so (e.g., you would not want a push
whose other end has hung up to report success).
This distinction doesn't typically matter in git, because we
do not ignore SIGPIPE in the first place. Which means that
we will not get EPIPE, but instead will just die when we get
a SIGPIPE. But it's possible for a default handler to be set
by a parent process, or for us to add a callsite inside one
of our few SIGPIPE-ignoring blocks of code.
This patch converts write_or_die to actually raise SIGPIPE
when we see EPIPE, rather than exiting with zero. This
brings the behavior in line with the "normal" case that we
die from SIGPIPE (and any callers who want to check why we
died will see the same thing). We also give the same
treatment to other related functions, including
write_or_whine_pipe and maybe_flush_or_die.
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'pkt-line.c')
0 files changed, 0 insertions, 0 deletions