From 9d726ba0fc7a64e57257922484fded17809489dc Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Mon, 15 Jul 2013 19:34:25 -0400 Subject: [PATCH] LIB: Simplify logic for get_exit_status(). Put caller to sleep until process exits, then check for it's exit status. --- lib/util.cpp | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/util.cpp b/lib/util.cpp index a1981a103a..c636d4e9a0 100644 --- a/lib/util.cpp +++ b/lib/util.cpp @@ -472,15 +472,8 @@ void kill_program(int pid) { #ifdef _WIN32 int get_exit_status(HANDLE pid_handle) { unsigned long status=1; - while (1) { - if (GetExitCodeProcess(pid_handle, &status)) { - if (status == STILL_ACTIVE) { - boinc_sleep(1); - } else { - break; - } - } - } + WaitForSingleObject(pid_handle, INFINITE); + GetExitCodeProcess(pid_handle, &status); return (int) status; } bool process_exists(HANDLE h) { @@ -490,7 +483,6 @@ bool process_exists(HANDLE h) { } return false; } - #else int get_exit_status(int pid) { int status;