nobug - restore unix_util.py for update verify r=bustate
authorNick Thomas <nthomas@mozilla.com>
Tue, 25 Sep 2018 14:34:08 +1200
changeset 8458 4f4834b9c6f7
parent 8457 400ef0a557ea
child 8459 2e92d95082d1
push id6181
push usernthomas@mozilla.com
push dateTue, 25 Sep 2018 02:34:16 +0000
reviewersbustate
nobug - restore unix_util.py for update verify r=bustate
buildfarm/utils/unix_util.py
new file mode 100644
--- /dev/null
+++ b/buildfarm/utils/unix_util.py
@@ -0,0 +1,20 @@
+import signal
+import os
+import time
+
+
+def kill(pid):
+    """Kill process pid with progressively more agressive signals."""
+    siglist = [signal.SIGINT, signal.SIGTERM]
+    while True:
+        if siglist:
+            sig = siglist.pop(0)
+        else:
+            sig = signal.SIGKILL
+        os.kill(pid, sig)
+        time.sleep(5)
+        rc = os.waitpid(pid, os.WNOHANG)
+        try:
+            os.kill(pid, 0)
+        except OSError:
+            return rc[1]