[PATCH xorg-gtest 2/4] process: if termination fails, the state must not be TERMINATED

Peter Hutterer peter.hutterer at who-t.net
Sun Oct 7 19:46:55 PDT 2012


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 at who-t.net>
---
 src/process.cpp | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/process.cpp b/src/process.cpp
index 555e56b..abd107d 100644
--- a/src/process.cpp
+++ b/src/process.cpp
@@ -158,8 +158,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:
@@ -184,12 +182,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) {
-- 
1.7.11.4



More information about the xorg-devel mailing list