def orphansKill(rootToKill, killsig=signal.SIGTERM):
"""kill off anything that is still chrooted."""
getLog().debug("kill orphans")
if USE_NSPAWN is False:
for fn in [d for d in os.listdir("/proc") if d.isdigit()]:
try:
root = os.readlink("/proc/%s/root" % fn)
if os.path.realpath(root) == os.path.realpath(rootToKill):
getLog().warning("Process ID %s still running in chroot. Killing...", fn)
pid = int(fn, 10)
os.kill(pid, killsig)
os.waitpid(pid, 0)
except OSError:
pass
else:
m_uuid = get_machinectl_uuid(rootToKill)
if m_uuid:
getLog().warning("Machine %s still running. Killing...", m_uuid)
os.system("/usr/bin/machinectl terminate %s" % m_uuid)
评论列表
文章目录