Skip to content

Commit f4f5498

Browse files
kusmagitster
authored andcommitted
mingw: correct exit-code for SIGALRM's SIG_DFL
Make sure SIG_DFL for SIGALRM exits with 128 + SIGALRM so other processes can diagnose why it exits. While we're at it, make sure we only write to stderr if it's a terminal, and change the output to match that of Linux. Signed-off-by: Erik Faye-Lund <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f94c325 commit f4f5498

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compat/mingw.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1560,8 +1560,11 @@ static sig_handler_t timer_fn = SIG_DFL;
15601560
static unsigned __stdcall ticktack(void *dummy)
15611561
{
15621562
while (WaitForSingleObject(timer_event, timer_interval) == WAIT_TIMEOUT) {
1563-
if (timer_fn == SIG_DFL)
1564-
die("Alarm");
1563+
if (timer_fn == SIG_DFL) {
1564+
if (isatty(STDERR_FILENO))
1565+
fputs("Alarm clock\n", stderr);
1566+
exit(128 + SIGALRM);
1567+
}
15651568
if (timer_fn != SIG_IGN)
15661569
timer_fn(SIGALRM);
15671570
if (one_shot)

0 commit comments

Comments
 (0)