diff options
-rw-r--r-- | win32/process.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/win32/process.c b/win32/process.c index 9a5ab417a..34ef3cffa 100644 --- a/win32/process.c +++ b/win32/process.c | |||
@@ -482,24 +482,22 @@ static int exit_code_to_wait_status_cmd(DWORD exit_code, const char *cmd) | |||
482 | return status << 8; | 482 | return status << 8; |
483 | } | 483 | } |
484 | 484 | ||
485 | static int exit_code_to_posix_cmd(DWORD exit_code, const char *cmd) | ||
486 | { | ||
487 | int status = exit_code_to_wait_status_cmd(exit_code, cmd); | ||
488 | |||
489 | if (WIFSIGNALED(status)) | ||
490 | return 128 + WTERMSIG(status); | ||
491 | return WEXITSTATUS(status); | ||
492 | } | ||
493 | |||
494 | static NORETURN void wait_for_child(HANDLE child, const char *cmd) | 485 | static NORETURN void wait_for_child(HANDLE child, const char *cmd) |
495 | { | 486 | { |
496 | DWORD code; | 487 | DWORD code; |
488 | int status; | ||
497 | 489 | ||
498 | kill_child_ctrl_handler(GetProcessId(child)); | 490 | kill_child_ctrl_handler(GetProcessId(child)); |
499 | SetConsoleCtrlHandler(kill_child_ctrl_handler, TRUE); | 491 | SetConsoleCtrlHandler(kill_child_ctrl_handler, TRUE); |
500 | WaitForSingleObject(child, INFINITE); | 492 | WaitForSingleObject(child, INFINITE); |
501 | GetExitCodeProcess(child, &code); | 493 | GetExitCodeProcess(child, &code); |
502 | exit(exit_code_to_posix_cmd(code, cmd)); | 494 | // We don't need the wait status, but get it anyway so the error |
495 | // message can include the command. In such cases we pass the | ||
496 | // exit status to exit() so our caller won't repeat the message. | ||
497 | status = exit_code_to_wait_status_cmd(code, cmd); | ||
498 | if (!WIFSIGNALED(status) && code > 0xff) | ||
499 | code = WEXITSTATUS(status); | ||
500 | exit((int)code); | ||
503 | } | 501 | } |
504 | 502 | ||
505 | int | 503 | int |
@@ -949,5 +947,9 @@ int exit_code_to_wait_status(DWORD exit_code) | |||
949 | 947 | ||
950 | int exit_code_to_posix(DWORD exit_code) | 948 | int exit_code_to_posix(DWORD exit_code) |
951 | { | 949 | { |
952 | return exit_code_to_posix_cmd(exit_code, NULL); | 950 | int status = exit_code_to_wait_status(exit_code); |
951 | |||
952 | if (WIFSIGNALED(status)) | ||
953 | return 128 + WTERMSIG(status); | ||
954 | return WEXITSTATUS(status); | ||
953 | } | 955 | } |