Skip to content

Commit 750a6ca

Browse files
committed
Merge branch 'jk/unify-exit-code-by-receiving-signal' into maint
* jk/unify-exit-code-by-receiving-signal: run-command: encode signal death as a positive integer
2 parents 32a03dc + 709ca73 commit 750a6ca

File tree

4 files changed

+5
-7
lines changed

4 files changed

+5
-7
lines changed

Documentation/technical/api-run-command.txt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ The functions above do the following:
5555
non-zero.
5656

5757
. If the program terminated due to a signal, then the return value is the
58-
signal number - 128, ie. it is negative and so indicates an unusual
59-
condition; a diagnostic is printed. This return value can be passed to
60-
exit(2), which will report the same code to the parent process that a
61-
POSIX shell's $? would report for a program that died from the signal.
58+
signal number + 128, ie. the same value that a POSIX shell's $? would
59+
report. A diagnostic is printed.
6260

6361

6462
`start_async`::

editor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ int launch_editor(const char *path, struct strbuf *buffer, const char *const *en
5151
sigchain_push(SIGINT, SIG_IGN);
5252
sigchain_push(SIGQUIT, SIG_IGN);
5353
ret = finish_command(&p);
54-
sig = ret + 128;
54+
sig = ret - 128;
5555
sigchain_pop(SIGINT);
5656
sigchain_pop(SIGQUIT);
5757
if (sig == SIGINT || sig == SIGQUIT)

run-command.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static int wait_or_whine(pid_t pid, const char *argv0)
249249
* mimics the exit code that a POSIX shell would report for
250250
* a program that died from this signal.
251251
*/
252-
code -= 128;
252+
code += 128;
253253
} else if (WIFEXITED(status)) {
254254
code = WEXITSTATUS(status);
255255
/*

t/test-terminal.perl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ sub finish_child {
3131
} elsif ($? & 127) {
3232
my $code = $? & 127;
3333
warn "died of signal $code";
34-
return $code - 128;
34+
return $code + 128;
3535
} else {
3636
return $? >> 8;
3737
}

0 commit comments

Comments
 (0)