diff mbox

[KVM-AUTOTEST] KVM test: kvm_subprocess: make is_alive() much shorter

Message ID 5f867ef244ef813dcf9e4c0f370aa79deee18558.1249835735.git.mgoldish@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Goldish Aug. 9, 2009, 4:36 p.m. UTC
Use a much shorter and simpler is_alive() instead of the current one.

Signed-off-by: Michael Goldish <mgoldish@redhat.com>
---
 client/tests/kvm/kvm_subprocess.py |   25 +------------------------
 1 files changed, 1 insertions(+), 24 deletions(-)
diff mbox

Patch

diff --git a/client/tests/kvm/kvm_subprocess.py b/client/tests/kvm/kvm_subprocess.py
index 41b9d80..dcb20cc 100644
--- a/client/tests/kvm/kvm_subprocess.py
+++ b/client/tests/kvm/kvm_subprocess.py
@@ -214,8 +214,6 @@  class kvm_spawn:
             # Wait for the server to complete its initialization
             while not "Server %s ready" % self.id in sub.stdout.readline():
                 pass
-            # Remember the start time for is_alive()
-            self.start_time = time.time()
 
         # Open the reading pipes
         self.reader_fds = {}
@@ -366,28 +364,7 @@  class kvm_spawn:
         """
         Return True if the process is running.
         """
-        pid = self.get_shell_pid()
-        # See if the PID exists
-        try:
-            os.kill(pid, 0)
-        except:
-            return False
-        # Make sure the PID belongs to the original process
-        filename = "/proc/%d/cmdline" % pid
-        try:
-            file = open(filename, "r")
-            cmdline = file.read()
-            file.close()
-        except:
-            # If we couldn't find the file for some reason, skip the check
-            return True
-        # If this process is new (less than 10 secs old) skip the check
-        if hasattr(self, "start_time") and time.time() < self.start_time + 10:
-            return True
-        # Perform the check
-        if self.id in cmdline:
-            return True
-        return False
+        return _locked(self.lock_server_running_filename)
 
 
     def close(self, sig=signal.SIGTERM):