From 66ae0ff56281e8f60a38c0ddea48fa8d7bc8d4a2 Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Thu, 22 Aug 2013 18:30:10 +0200 Subject: [PATCH] process: make the 'status' parameter for exit_cb an int64_t This means we no longer have to strip the high bit from the process exit code on Windows, which is problematic because an unhandled SEH exception can make a process exit with a status code that has the high bit set. --- include/uv.h | 2 +- src/win/process.c | 3 --- test/benchmark-spawn.c | 4 +++- test/test-ipc.c | 4 +++- test/test-spawn.c | 18 +++++++++++------- test/test-stdio-over-pipes.c | 4 +++- 6 files changed, 21 insertions(+), 14 deletions(-) diff --git a/include/uv.h b/include/uv.h index 5821cce8..32d481b2 100644 --- a/include/uv.h +++ b/include/uv.h @@ -384,7 +384,7 @@ typedef void (*uv_async_cb)(uv_async_t* handle, int status); typedef void (*uv_prepare_cb)(uv_prepare_t* handle, int status); typedef void (*uv_check_cb)(uv_check_t* handle, int status); typedef void (*uv_idle_cb)(uv_idle_t* handle, int status); -typedef void (*uv_exit_cb)(uv_process_t*, int exit_status, int term_signal); +typedef void (*uv_exit_cb)(uv_process_t*, int64_t exit_status, int term_signal); typedef void (*uv_walk_cb)(uv_handle_t* handle, void* arg); typedef void (*uv_fs_cb)(uv_fs_t* req); typedef void (*uv_work_cb)(uv_work_t* req); diff --git a/src/win/process.c b/src/win/process.c index 7f1c10dc..13dc9d10 100644 --- a/src/win/process.c +++ b/src/win/process.c @@ -758,9 +758,6 @@ void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) { } else if (!GetExitCodeProcess(handle->process_handle, &status)) { /* Unable to to obtain the exit code. This should never happen. */ exit_code = uv_translate_sys_error(GetLastError()); - } else { - /* Make sure the exit code is >= 0. */ - exit_code = status & INT_MAX; } /* Fire the exit callback. */ diff --git a/test/benchmark-spawn.c b/test/benchmark-spawn.c index 4912d978..140bfa76 100644 --- a/test/benchmark-spawn.c +++ b/test/benchmark-spawn.c @@ -64,7 +64,9 @@ static void process_close_cb(uv_handle_t* handle) { } -static void exit_cb(uv_process_t* process, int exit_status, int term_signal) { +static void exit_cb(uv_process_t* process, + int64_t exit_status, + int term_signal) { ASSERT(exit_status == 42); ASSERT(term_signal == 0); uv_close((uv_handle_t*)process, process_close_cb); diff --git a/test/test-ipc.c b/test/test-ipc.c index ba9c7a3e..0918a927 100644 --- a/test/test-ipc.c +++ b/test/test-ipc.c @@ -84,7 +84,9 @@ static void on_connection(uv_stream_t* server, int status) { } -static void exit_cb(uv_process_t* process, int exit_status, int term_signal) { +static void exit_cb(uv_process_t* process, + int64_t exit_status, + int term_signal) { printf("exit_cb\n"); exit_cb_called++; ASSERT(exit_status == 0); diff --git a/test/test-spawn.c b/test/test-spawn.c index 507ef2d5..96cc307a 100644 --- a/test/test-spawn.c +++ b/test/test-spawn.c @@ -52,7 +52,9 @@ static void close_cb(uv_handle_t* handle) { } -static void exit_cb(uv_process_t* process, int exit_status, int term_signal) { +static void exit_cb(uv_process_t* process, + int64_t exit_status, + int term_signal) { printf("exit_cb\n"); exit_cb_called++; ASSERT(exit_status == 1); @@ -62,7 +64,7 @@ static void exit_cb(uv_process_t* process, int exit_status, int term_signal) { static void expect(uv_process_t* process, - int exit_status, + int64_t exit_status, int term_signal, int err) { printf("exit_cb\n"); @@ -74,20 +76,22 @@ static void expect(uv_process_t* process, static void exit_cb_expect_enoent(uv_process_t* process, - int exit_status, + int64_t exit_status, int term_signal) { expect(process, exit_status, term_signal, UV_ENOENT); } static void exit_cb_expect_eperm(uv_process_t* process, - int exit_status, + int64_t exit_status, int term_signal) { expect(process, exit_status, term_signal, UV_EPERM); } -static void kill_cb(uv_process_t* process, int exit_status, int term_signal) { +static void kill_cb(uv_process_t* process, + int64_t exit_status, + int term_signal) { int err; printf("exit_cb\n"); @@ -109,7 +113,7 @@ static void kill_cb(uv_process_t* process, int exit_status, int term_signal) { ASSERT(err == UV_ESRCH); } -static void detach_failure_cb(uv_process_t* process, int exit_status, int term_signal) { +static void detach_failure_cb(uv_process_t* process, int64_t exit_status, int term_signal) { printf("detach_cb\n"); exit_cb_called++; } @@ -886,7 +890,7 @@ TEST_IMPL(spawn_setgid_fails) { #ifdef _WIN32 static void exit_cb_unexpected(uv_process_t* process, - int exit_status, + int64_t exit_status, int term_signal) { ASSERT(0 && "should not have been called"); } diff --git a/test/test-stdio-over-pipes.c b/test/test-stdio-over-pipes.c index 99b09160..1d6191e7 100644 --- a/test/test-stdio-over-pipes.c +++ b/test/test-stdio-over-pipes.c @@ -48,7 +48,9 @@ static void close_cb(uv_handle_t* handle) { } -static void exit_cb(uv_process_t* process, int exit_status, int term_signal) { +static void exit_cb(uv_process_t* process, + int64_t exit_status, + int term_signal) { printf("exit_cb\n"); exit_cb_called++; ASSERT(exit_status == 0);