From: Johannes Sixt Date: Sat, 4 Jul 2009 19:26:41 +0000 (+0200) Subject: run_command: encode deadly signal number in the return value X-Git-Tag: v1.6.5-rc0~86^2~4 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=b99d5f40d6a5cba7d7cd7599063b3cd78aa4d219;p=git.git 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. Signed-off-by: Johannes Sixt Signed-off-by: Junio C Hamano --- diff --git a/run-command.c b/run-command.c index e273c6c45..30c2b3dd8 100644 --- a/run-command.c +++ b/run-command.c @@ -248,7 +248,14 @@ static int wait_or_whine(pid_t pid, const char *argv0) } else if (waiting != pid) { error("waitpid is confused (%s)", argv0); } else if (WIFSIGNALED(status)) { - error("%s died of signal", argv0); + code = WTERMSIG(status); + error("%s died of signal %d", argv0, code); + /* + * This return value is chosen so that code & 0xff + * mimics the exit code that a POSIX shell would report for + * a program that died from this signal. + */ + code -= 128; } else if (WIFEXITED(status)) { code = WEXITSTATUS(status); /*