From be8fc53e364211856cca7affa4472855f96f8fa9 Mon Sep 17 00:00:00 2001 From: Ævar Arnfjörð Bjarmason Date: Tue, 2 Feb 2021 03:00:00 +0100 Subject: pager: properly log pager exit code when signalled MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- run-command.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'run-command.c') 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) { -- cgit v1.3