From: Jeff King <peff@peff.net>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: Duy Nguyen <pclouds@gmail.com>,
Git Mailing List <git@vger.kernel.org>,
Junio C Hamano <gitster@pobox.com>, Johannes Sixt <j6t@kdbg.org>,
Jonathan Nieder <jrnieder@gmail.com>,
"John J. Franey" <jjfraney@gmail.com>
Subject: Re: [PATCH] run-command: simplify wait_or_whine
Date: Sat, 1 Jun 2013 13:01:48 -0400 [thread overview]
Message-ID: <20130601170147.GA19234@sigill.intra.peff.net> (raw)
In-Reply-To: <CAMP44s0L1M+_s2eDM=Ogy=rxLhpZYwSb8qWTuEe30pB4KGDVtA@mail.gmail.com>
On Sat, Jun 01, 2013 at 09:30:50AM -0500, Felipe Contreras wrote:
> > The original commit that introduces this says
> >
> > run_command: encode deadly signal number in the return value
> >
> > We now write the signal number in the error message if the program
> > terminated by a signal. The negative return value is constructed such that
> > after truncation to 8 bits it looks like a POSIX shell's $?:
> >
> > $ echo 0000 | { git upload-pack .; echo $? >&2; } | :
> > error: git-upload-pack died of signal 13
> > 141
> >
> > Previously, the exit code was 255 instead of 141.
> >
> > So this is part of the interface to the user. With your changes, the
> > exit code is now different. I tested by force segfaulting upload-pack.
> > $? returned 11. So NAK.
>
> Yeah, and last year we returned a different code. The world didn't
> end, because nobody is checking for the specific code. But if you want
> to retain complexity forever, suit yourselves.
Last year we returned a different code from the function that other C
code saw. But what got returned via exit() to exterior programs was
always 141 in the SIGPIPE case, both before and after my 709ca730. That
is explained in the first two paragraphs here:
> commit 709ca730f8e093005cc882bfb86c0ca9c83d345b
> Author: Jeff King <peff@peff.net>
> Date: Sat Jan 5 09:49:49 2013 -0500
>
> run-command: encode signal death as a positive integer
>
> When a sub-command dies due to a signal, we encode the
> signal number into the numeric exit status as "signal -
> 128". This is easy to identify (versus a regular positive
> error code), and when cast to an unsigned integer (e.g., by
> feeding it to exit), matches what a POSIX shell would return
> when reporting a signal death in $? or through its own exit
> code.
>
> So we have a negative value inside the code, but once it
> passes across an exit() barrier, it looks positive (and any
> code we receive from a sub-shell will have the positive
> form). E.g., death by SIGPIPE (signal 13) will look like
> -115 to us in inside git, but will end up as 141 when we
> call exit() with it. And a program killed by SIGPIPE but run
> via the shell will come to us with an exit code of 141.
Your patch changes the error code that is propagated via exit() in this
case. We cannot know "nobody is checking for the specific code", because
the list of callers is every shell script or program which execs git.
Some of them do care about the exit code. I can give an example of a
case I have that cares, but I do not think it is even important. The
point is that we would be regressing an existing interface, and cannot
know who is broken by it.
-Peff
next prev parent reply other threads:[~2013-06-01 17:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-01 13:51 [PATCH] run-command: simplify wait_or_whine Felipe Contreras
2013-06-01 14:03 ` Duy Nguyen
2013-06-01 14:06 ` Felipe Contreras
2013-06-01 14:08 ` Duy Nguyen
2013-06-01 14:20 ` Felipe Contreras
2013-06-01 14:19 ` Thomas Rast
2013-06-01 14:23 ` Felipe Contreras
2013-06-01 14:21 ` Duy Nguyen
2013-06-01 14:30 ` Felipe Contreras
2013-06-01 14:36 ` Duy Nguyen
2013-06-01 15:01 ` Felipe Contreras
2013-06-01 17:24 ` [PATCH] t0005: test git exit code from signal death Jeff King
2013-06-01 21:41 ` Felipe Contreras
2013-06-01 17:01 ` Jeff King [this message]
2013-06-01 21:35 ` [PATCH] run-command: simplify wait_or_whine Felipe Contreras
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130601170147.GA19234@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=jjfraney@gmail.com \
--cc=jrnieder@gmail.com \
--cc=pclouds@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).