From d667653f77729b03fd63978d7e032e3c2b5f607c Mon Sep 17 00:00:00 2001 From: Bert Belder Date: Sat, 24 Aug 2013 16:24:14 +0200 Subject: [PATCH] windows: report uv_process_t exit code correctly A stupid oversight in 66ae0ff would cause a random value to be reported as the exit code for a 'normally exited' child process. --- src/win/process.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/win/process.c b/src/win/process.c index 13dc9d10..477e5e41 100644 --- a/src/win/process.c +++ b/src/win/process.c @@ -729,7 +729,7 @@ static void CALLBACK exit_wait_callback(void* data, BOOLEAN didTimeout) { /* Called on main thread after a child process has exited. */ void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) { - int exit_code; + int64_t exit_code; DWORD status; assert(handle->exit_cb_pending); @@ -755,7 +755,9 @@ void uv_process_proc_exit(uv_loop_t* loop, uv_process_t* handle) { if (handle->spawn_error) { /* Spawning failed. */ exit_code = uv_translate_sys_error(handle->spawn_error); - } else if (!GetExitCodeProcess(handle->process_handle, &status)) { + } else if (GetExitCodeProcess(handle->process_handle, &status)) { + exit_code = status; + } else { /* Unable to to obtain the exit code. This should never happen. */ exit_code = uv_translate_sys_error(GetLastError()); }