Attached is patch that will kill (via SIGTERM, then if that fails, via
SIGKILL),
these leftover processes.
diff --git a/piuparts.py b/piuparts.py
--- a/piuparts.py
+++ b/piuparts.py
@@ -37,11 +37,9 @@
import logging
import optparse
import sys
-import commands
import tempfile
import shutil
import os
-import tarfile
import stat
import re
import pickle
@@ -49,6 +47,7 @@
import unittest
import urllib
import uuid
+from signal import signal, SIGTERM, SIGKILL
try:
from debian import deb822
@@ -1034,6 +1033,21 @@
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()