summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael E Brown <mebrown@michaels-house.net>2007-10-19 00:04:16 -0500
committerMichael E Brown <mebrown@michaels-house.net>2007-10-19 00:04:16 -0500
commit1ad3ce09fe263baa3484afd38e89b7078f9b3ca2 (patch)
tree1df02f05727b84d9fe9dba010980750f10035aba /src
parent0e08a556bdb2d6e45d5e33c3c96d9188f6449838 (diff)
downloadmock-1ad3ce09fe263baa3484afd38e89b7078f9b3ca2.tar.gz
mock-1ad3ce09fe263baa3484afd38e89b7078f9b3ca2.tar.xz
mock-1ad3ce09fe263baa3484afd38e89b7078f9b3ca2.zip
add orphansKill() function. Kills off everything with a specific root dir.
Diffstat (limited to 'src')
-rw-r--r--src/py-libs/util.py13
1 files changed, 13 insertions, 0 deletions
diff --git a/src/py-libs/util.py b/src/py-libs/util.py
index 868fb41..f2d13f6 100644
--- a/src/py-libs/util.py
+++ b/src/py-libs/util.py
@@ -73,6 +73,19 @@ def rmtree(*args, **kargs):
raise
@traceLog(log)
+def orphansKill(rootToKill):
+ """kill off anything that is still chrooted."""
+ for fn in os.listdir("/proc"):
+ try:
+ root = os.readlink("/proc/%s/root" % fn)
+ if root == rootToKill:
+ log.warning("Process ID %s still running in chroot. Killing..." % fn)
+ os.kill(int(fn,10), 15)
+ except OSError, e:
+ pass
+
+
+@traceLog(log)
def yieldSrpmHeaders(srpms):
ts = rpmUtils.transaction.initReadOnlyTransaction()
for srpm in srpms: