Add write_pid to common code
Call write_pid from scheduler and babysitter
Signed-off-by: Rachel Kroll <rkroll@google.com>
git-svn-id: http://test.kernel.org/svn/autotest/trunk@2953 592f7852-d20e-0410-864c-8624ca9c26a4
diff --git a/client/common_lib/utils.py b/client/common_lib/utils.py
index 77cc68e..d728c34 100644
--- a/client/common_lib/utils.py
+++ b/client/common_lib/utils.py
@@ -882,3 +882,19 @@
"""
return import_site_symbol(path, module, funcname, dummy, modulefile)
+
+
+def write_pid(program_name):
+ """
+ Try to drop <program_name>.pid in the main autotest directory.
+
+ Args:
+ program_name: prefix for file name
+ """
+
+ my_path = os.path.dirname(__file__)
+ pid_path = os.path.abspath(os.path.join(my_path, "../.."))
+ pidf = open(os.path.join(pid_path, "%s.pid" % program_name), "w")
+ if pidf:
+ pidf.write("%s\n" % os.getpid())
+ pidf.close()