diff mbox

[Autotest,1/4] This add utils for get process name from his PID.

Message ID 1286979199-13109-2-git-send-email-jzupka@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Jiri Zupka Oct. 13, 2010, 2:13 p.m. UTC
None
diff mbox

Patch

diff --git a/client/common_lib/utils.py b/client/common_lib/utils.py
index 2cbc740..8d6c1f7 100644
--- a/client/common_lib/utils.py
+++ b/client/common_lib/utils.py
@@ -1105,6 +1105,14 @@  def get_pid_from_file(program_name):
     return pid
 
 
+def get_process_name(pid):
+    """
+    Get process name from PID.
+    @param pid: PID of process.
+    """
+    return get_field(read_file("/proc/%d/stat" % pid), 1)[1:-1]
+
+
 def program_is_alive(program_name):
     """
     Checks if the process is alive and not in Zombie state.