def force_kill_all_children():
""" Iterate through all known child processes and force kill them. In the future we might consider
possibly giving the child processes time to exit but this is fine for now. If someone force kills
us and does not clean the process tree this will leave child processes around unless they choose
to end themselves if their parent process dies. """
# First uninstall the SIGCHLD handler so that we don't get called again.
signal.signal(signal.SIGCHLD, signal.SIG_DFL)
global pid_list
for pid in pid_list:
print ("force killing PID={}".format(pid))
try:
os.kill(pid, signal.SIGKILL)
except:
print ("error force killing PID={} continuing".format(pid))
pid_list = []
评论列表
文章目录