LIB: Simplify logic for get_exit_status(). Put caller to sleep until process exits, then check for it's exit status.

This commit is contained in:
Rom Walton 2013-07-15 19:34:25 -04:00
parent 88135a7000
commit 9d726ba0fc
1 changed files with 2 additions and 10 deletions

View File

@ -472,15 +472,8 @@ void kill_program(int pid) {
#ifdef _WIN32 #ifdef _WIN32
int get_exit_status(HANDLE pid_handle) { int get_exit_status(HANDLE pid_handle) {
unsigned long status=1; unsigned long status=1;
while (1) { WaitForSingleObject(pid_handle, INFINITE);
if (GetExitCodeProcess(pid_handle, &status)) { GetExitCodeProcess(pid_handle, &status);
if (status == STILL_ACTIVE) {
boinc_sleep(1);
} else {
break;
}
}
}
return (int) status; return (int) status;
} }
bool process_exists(HANDLE h) { bool process_exists(HANDLE h) {
@ -490,7 +483,6 @@ bool process_exists(HANDLE h) {
} }
return false; return false;
} }
#else #else
int get_exit_status(int pid) { int get_exit_status(int pid) {
int status; int status;