From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Johannes Sixt <j6t@kdbg.org>,
git@vger.kernel.org, Bart Trojanowski <bart@jukie.net>
Subject: Re: [PATCH] run-command: encode signal death as a positive integer
Date: Sat, 05 Jan 2013 23:05:54 -0800 [thread overview]
Message-ID: <7v38yepz8t.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20130105144949.GA24479@sigill.intra.peff.net> (Jeff King's message of "Sat, 5 Jan 2013 09:49:49 -0500")
Jeff King <peff@peff.net> writes:
> On Sat, Jan 05, 2013 at 09:03:16AM -0500, Jeff King wrote:
> ...
> The downside is that callers of run_command can no longer
> differentiate between a signal received directly by the
> sub-process, and one propagated. However, no caller
> currently cares, and since we already optimize out some
> calls to the shell under the hood, that distinction is not
> something that should be relied upon by callers.
>
> Signed-off-by: Jeff King <peff@peff.net>
> ---
Very nicely explained. Thanks.
> Documentation/technical/api-run-command.txt | 6 ++----
> editor.c | 2 +-
> run-command.c | 2 +-
> 3 files changed, 4 insertions(+), 6 deletions(-)
>
> diff --git a/Documentation/technical/api-run-command.txt b/Documentation/technical/api-run-command.txt
> index f18b4f4..5d7d7f2 100644
> --- a/Documentation/technical/api-run-command.txt
> +++ b/Documentation/technical/api-run-command.txt
> @@ -55,10 +55,8 @@ The functions above do the following:
> non-zero.
>
> . If the program terminated due to a signal, then the return value is the
> - signal number - 128, ie. it is negative and so indicates an unusual
> - condition; a diagnostic is printed. This return value can be passed to
> - exit(2), which will report the same code to the parent process that a
> - POSIX shell's $? would report for a program that died from the signal.
> + signal number + 128, ie. the same value that a POSIX shell's $? would
> + report. A diagnostic is printed.
>
>
> `start_async`::
> diff --git a/editor.c b/editor.c
> index 065a7ab..27bdecd 100644
> --- a/editor.c
> +++ b/editor.c
> @@ -51,7 +51,7 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
> sigchain_push(SIGINT, SIG_IGN);
> sigchain_push(SIGQUIT, SIG_IGN);
> ret = finish_command(&p);
> - sig = ret + 128;
> + sig = ret - 128;
> sigchain_pop(SIGINT);
> sigchain_pop(SIGQUIT);
> if (sig == SIGINT || sig == SIGQUIT)
> diff --git a/run-command.c b/run-command.c
> index 757f263..cfb7274 100644
> --- a/run-command.c
> +++ b/run-command.c
> @@ -249,7 +249,7 @@ static int wait_or_whine(pid_t pid, const char *argv0)
> * mimics the exit code that a POSIX shell would report for
> * a program that died from this signal.
> */
> - code -= 128;
> + code += 128;
> } else if (WIFEXITED(status)) {
> code = WEXITSTATUS(status);
> /*
next prev parent reply other threads:[~2013-01-06 7:06 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-04 12:47 [RFC/PATCH] avoid SIGPIPE warnings for aliases Jeff King
2013-01-04 16:55 ` Johannes Sixt
2013-01-04 21:25 ` Jeff King
2013-01-04 22:20 ` Junio C Hamano
2013-01-05 14:03 ` Jeff King
2013-01-05 14:49 ` [PATCH] run-command: encode signal death as a positive integer Jeff King
2013-01-05 19:50 ` Johannes Sixt
2013-01-05 22:19 ` Jonathan Nieder
2013-01-05 23:12 ` Jeff King
2013-01-05 23:58 ` Jonathan Nieder
2013-01-06 7:05 ` Junio C Hamano [this message]
2013-01-09 20:48 ` [RFC/PATCH] avoid SIGPIPE warnings for aliases Junio C Hamano
2013-01-09 20:51 ` Jeff King
2013-01-09 21:49 ` Junio C Hamano
2013-01-10 0:18 ` Jonathan Nieder
2013-01-10 0:39 ` Junio C Hamano
2013-01-10 11:26 ` Jeff King
2013-01-10 20:22 ` Junio C Hamano
2013-01-10 21:39 ` Jeff King
2013-01-10 21:52 ` Johannes Sixt
2013-01-10 22:51 ` Junio C Hamano
2013-01-10 10:49 ` Jeff King
2014-07-21 6:45 ` mimimimi
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=7v38yepz8t.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=bart@jukie.net \
--cc=git@vger.kernel.org \
--cc=j6t@kdbg.org \
--cc=peff@peff.net \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).