zombie-process

How can I prevent zombie child processes?

≯℡__Kan透↙ 提交于 2019-11-26 20:03:20
问题 I am writing a server that uses fork() to spawn handlers for client connections. The server does not need to know about what happens to the forked processes – they work on their own, and when they're done, they should just die instead of becoming zombies. What is an easy way to accomplish this? 回答1: There are several ways, but using sigaction with SA_NOCLDWAIT in the parent process is probably the easiest one: struct sigaction sigchld_action = { .sa_handler = SIG_DFL, .sa_flags = SA_NOCLDWAIT

Ensuring subprocesses are dead on exiting Python program

懵懂的女人 提交于 2019-11-26 17:58:52
问题 Is there a way to ensure all created subprocess are dead at exit time of a Python program? By subprocess I mean those created with subprocess.Popen(). If not, should I iterate over all of the issuing kills and then kills -9? anything cleaner? 回答1: You can use atexit for this, and register any clean up tasks to be run when your program exits. atexit.register(func[, *args[, **kargs]]) In your cleanup process, you can also implement your own wait, and kill it when a your desired timeout occurs.