]> git.ipfire.org Git - pakfire.git/commitdiff
After killing all processes in the chroot, wait a bit.
authorMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Oct 2011 21:25:48 +0000 (23:25 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Mon, 3 Oct 2011 21:25:48 +0000 (23:25 +0200)
This is needed because processes to not close their file
descriptors fast enough to umount directories.

python/pakfire/util.py

index 1ba2992a22a41ffafac417e1ecc569bbca485bd3..7d1690ab55d9c5c831b3cd437101cf784bdb88f8 100644 (file)
@@ -249,13 +249,15 @@ def orphans_kill(root, killsig=signal.SIGTERM):
        """
                kill off anything that is still chrooted.
        """
-       logging.debug("Killing orphans...")
+       logging.debug(_("Killing orphans..."))
 
+       killed = False
        for fn in [d for d in os.listdir("/proc") if d.isdigit()]:
                try:
                        r = os.readlink("/proc/%s/root" % fn)
                        if os.path.realpath(root) == os.path.realpath(r):
-                               logging.warning("Process ID %s is still running in chroot. Killing..." % fn)
+                               logging.warning(_("Process ID %s is still running in chroot. Killing...") % fn)
+                               killed = True
 
                                pid = int(fn, 10)
                                os.kill(pid, killsig)
@@ -263,6 +265,12 @@ def orphans_kill(root, killsig=signal.SIGTERM):
                except OSError, e:
                        pass
 
+       # If something was killed, wait a couple of seconds to make sure all file descriptors
+       # are closed and we can proceed with umounting the filesystems.
+       if killed:
+               logging.warning(_("Waiting for processes to terminate..."))
+               time.sleep(3)
+
 def scriptlet_interpreter(scriptlet):
        """
                This function returns the interpreter of a scriptlet.