diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2012-09-26 14:19:03 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2012-10-10 08:24:32 +1000 |
commit | d2e680f9d372510cfa8c1d268a0abeda266bfe8c (patch) | |
tree | 298f1a50798f20ce1b0154b4b1b9c295e498b6fe | |
parent | d4873441a0afc083963a392ad422e3187e60a159 (diff) |
process: if termination fails, the state must not be TERMINATED
If a process is hung and doesn't respond to termination, a Kill() call must
still try to actually kill the process. In the current code, unsuccessful
termination would still set the state, preventing Kill() from actually
working
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@ubuntu.com>
-rw-r--r-- | src/process.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/process.cpp b/src/process.cpp index 4deea14..a9c041e 100644 --- a/src/process.cpp +++ b/src/process.cpp @@ -143,8 +143,6 @@ bool xorg::testing::Process::WaitForExit(unsigned int timeout) { } bool xorg::testing::Process::KillSelf(int signal, unsigned int timeout) { - bool wait_success = true; - enum State state = GetState(); switch (state) { case FINISHED_SUCCESS: @@ -169,12 +167,17 @@ bool xorg::testing::Process::KillSelf(int signal, unsigned int timeout) { d_->state = ERROR; return false; } - if (timeout > 0) + if (timeout > 0) { + bool wait_success = true; + wait_success = WaitForExit(timeout); + if (!wait_success) + return false; + } d_->pid = -1; } d_->state = TERMINATED; - return wait_success; + return true; } bool xorg::testing::Process::Terminate(unsigned int timeout) { |