diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-10-09 18:38:30 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-10-10 11:15:37 +1000 |
commit | da8f1822384e4057774055fce9589bcf3da03304 (patch) | |
tree | b90f59bb30511b342b08559396951fce2b5787d7 /src | |
parent | 200e0d8554f8930ac7cde839376579681140f0e6 (diff) |
process: on termination, check if the process exited and set the error code
This changes the meaning of Process::TERMINATED to "currently in termination
but we're not sure what happened to it"
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@ubuntu.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/process.cpp | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/process.cpp b/src/process.cpp index a9c041e..0b0ddc3 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -131,9 +131,15 @@ bool xorg::testing::Process::WaitForExit(unsigned int timeout) { int status; int pid = waitpid(Pid(), &status, WNOHANG); - if (pid == Pid()) - return true; - else if (pid == -1) + if (pid == Pid()) { + if (WIFEXITED(status)) { + d_->state = WEXITSTATUS(status) ? FINISHED_FAILURE : FINISHED_SUCCESS; + return true; + } else if (WIFSIGNALED(status)) { + d_->state = FINISHED_FAILURE; + return true; + } + } else if (pid == -1) return errno == ECHILD; usleep(10); @@ -171,8 +177,9 @@ bool xorg::testing::Process::KillSelf(int signal, unsigned int timeout) { bool wait_success = true; wait_success = WaitForExit(timeout); - if (!wait_success) - return false; + if (wait_success) + d_->pid = -1; + return wait_success; } d_->pid = -1; } |