LIB: Possible fix for process_exists() on Linux. Newer versions of Linux appear to have stricter parameter validation requirements for waitpid().

This commit is contained in:
Rom Walton 2014-03-25 13:14:45 -04:00
parent 292f216a6c
commit 6c42a3fff7
1 changed files with 2 additions and 1 deletions

View File

@ -491,7 +491,8 @@ int get_exit_status(int pid) {
return status;
}
bool process_exists(int pid) {
int p = waitpid(pid, 0, WNOHANG);
int status;
int p = waitpid(pid, &status, WNOHANG);
if (p == pid) return false; // process has exited
if (p == -1) return false; // PID doesn't exist
return true;