diff options
author | Junio C Hamano <gitster@pobox.com> | 2021-12-10 14:35:13 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-12-10 14:35:13 -0800 |
commit | 97991dfab7bea2f347bbea1ae7494afa72a50931 (patch) | |
tree | 0b816d475d5055aaa0ebdaa6fc2d480f02e15fe4 /run-command.c | |
parent | Merge branch 'jk/refs-g11-workaround' (diff) | |
parent | t7006: simplify exit-code checks for sigpipe tests (diff) | |
download | tgif-97991dfab7bea2f347bbea1ae7494afa72a50931.tar.xz |
Merge branch 'jk/t7006-sigpipe-tests-fix'
The function to cull a child process and determine the exit status
had two separate code paths for normal callers and callers in a
signal handler, and the latter did not yield correct value when the
child has caught a signal. The handling of the exit status has
been unified for these two code paths. An existing test with
flakiness has also been corrected.
* jk/t7006-sigpipe-tests-fix:
t7006: simplify exit-code checks for sigpipe tests
t7006: clean up SIGPIPE handling in trace2 tests
run-command: unify signal and regular logic for wait_or_whine()
Diffstat (limited to 'run-command.c')
-rw-r--r-- | run-command.c | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/run-command.c b/run-command.c index f40df01c77..1f58c17b6c 100644 --- a/run-command.c +++ b/run-command.c @@ -552,20 +552,17 @@ 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) { - if (WIFEXITED(status)) - code = WEXITSTATUS(status); - return code; - } if (waiting < 0) { failed_errno = errno; - error_errno("waitpid for %s failed", argv0); + if (!in_signal) + error_errno("waitpid for %s failed", argv0); } else if (waiting != pid) { - error("waitpid is confused (%s)", argv0); + if (!in_signal) + error("waitpid is confused (%s)", argv0); } else if (WIFSIGNALED(status)) { code = WTERMSIG(status); - if (code != SIGINT && code != SIGQUIT && code != SIGPIPE) + if (!in_signal && code != SIGINT && code != SIGQUIT && code != SIGPIPE) error("%s died of signal %d", argv0, code); /* * This return value is chosen so that code & 0xff @@ -576,10 +573,12 @@ static int wait_or_whine(pid_t pid, const char *argv0, int in_signal) } else if (WIFEXITED(status)) { code = WEXITSTATUS(status); } else { - error("waitpid is confused (%s)", argv0); + if (!in_signal) + error("waitpid is confused (%s)", argv0); } - clear_child_for_cleanup(pid); + if (!in_signal) + clear_child_for_cleanup(pid); errno = failed_errno; return code; |