[Piuparts-commits] [SCM] piuparts git repository branch, master, updated. eda668423fa87898c59d1075118693714aa5a053
Holger Levsen
holger at layer-acht.org
Fri Dec 23 10:25:17 UTC 2011
The following commit has been merged in the master branch:
commit 3e4c3ea7c531244a5a06d1b86c81866ab7a2ea2c
Author: Holger Levsen <holger at layer-acht.org>
Date: Sun Oct 2 10:32:13 2011 +0200
piuparty.py: kill (via SIGTERM, then if that fails, via SIGKILL), leftover processes. (Closes: #522918) Thanks to Scott Schaefer for the patch.
re-create accidentily deleted branch.
diff --git a/debian/changelog b/debian/changelog
index 3500141..b9ce8b0 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,8 @@ piuparts (0.42) UNRELEASED; urgency=low
* piuparts-slave.py: Replace deprecated os.popen2 with subprocess.Popen,
thanks to Scott Schaefer and Evgeni Golov for their patches.
(Closes: #640646)
+ * piuparty.py: kill (via SIGTERM, then if that fails, via SIGKILL), leftover
+ processes. (Closes: #522918) Thanks to Scott Schaefer for the patch.
[ Mika Pflüger ]
* piuparts-analyze.py: Rewrite to use python-debianbts to analyze if bugs
diff --git a/piuparts.py b/piuparts.py
index a731af2..efb0aec 100644
--- a/piuparts.py
+++ b/piuparts.py
@@ -49,6 +49,7 @@ import subprocess
import unittest
import urllib
import uuid
+from signal import signal, SIGTERM, SIGKILL
try:
from debian import deb822
@@ -992,6 +993,21 @@ class Chroot:
if count > 0:
logging.error("FAIL: Processes are running inside chroot:\n%s" %
indent_string(output))
+ for signo in [ 15, 9 ]:
+ p = subprocess.Popen(["lsof", "-t", "+D", self.name],
+ stdin=subprocess.PIPE, stdout=subprocess.PIPE)
+ stdout, _ = p.communicate()
+ if stdout:
+ pidlist = [int(pidstr) for pidstr in stdout.split("\n") if len(pidstr)]
+ for pid in pidlist:
+ if pid > 0:
+ try:
+ if signo == 15:
+ os.kill(pid, SIGTERM)
+ else:
+ os.kill(pid, SIGKILL)
+ except OSError:
+ pass
panic()
--
piuparts git repository
More information about the Piuparts-commits
mailing list