diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-02-02 03:00:00 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-02-01 21:15:58 -0800 |
commit | be8fc53e364211856cca7affa4472855f96f8fa9 (patch) | |
tree | 4229319ea2b3c7819e719dbb2a8fed3b27d632c8 /run-command.c | |
parent | run-command: add braces for "if" block in wait_or_whine() (diff) | |
download | tgif-be8fc53e364211856cca7affa4472855f96f8fa9.tar.xz |
pager: properly log pager exit code when signalled
When git invokes a pager that exits with non-zero the common case is
that we'll already return the correct SIGPIPE failure from git itself,
but the exit code logged in trace2 has always been incorrectly
reported[1]. Fix that and log the correct exit code in the logs.
Since this gives us something to test outside of our recently-added
tests needing a !MINGW prerequisite, let's refactor the test to run on
MINGW and actually check for SIGPIPE outside of MINGW.
The wait_or_whine() is only called with a true "in_signal" from from
finish_command_in_signal(), which in turn is only used in pager.c.
The "in_signal && !WIFEXITED(status)" case is not covered by
tests. Let's log the default -1 in that case for good measure.
1. The incorrect logging of the exit code in was seemingly copy/pasted
into finish_command_in_signal() in ee4512ed481 (trace2: create new
combined trace facility, 2019-02-22)
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'run-command.c')
-rw-r--r-- | run-command.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/run-command.c b/run-command.c index 00e68f37ab..509841bf27 100644 --- a/run-command.c +++ b/run-command.c @@ -552,7 +552,9 @@ static int wait_or_whine(pid_t pid, const char *argv0, int in_signal) while ((waiting = waitpid(pid, &status, 0)) < 0 && errno == EINTR) ; /* nothing */ if (in_signal) { - return 0; + if (WIFEXITED(status)) + code = WEXITSTATUS(status); + return code; } if (waiting < 0) { |