How to kill a child process by the parent process?

Send a SIGTERM or a SIGKILL to it: http://en.wikipedia.org/wiki/SIGKILL http://en.wikipedia.org/wiki/SIGTERM SIGTERM is polite and lets the process clean up before it goes, whereas, SIGKILL is for when it won’t listen >:) Example from the shell (man page: http://unixhelp.ed.ac.uk/CGI/man-cgi?kill ) kill -9 pid In C, you can do the same thing using the kill syscall: kill(pid, … Read more

multiprocessing fork() vs spawn()

There’s a tradeoff between 3 multiprocessing start methods: fork is faster because it does a copy-on-write of the parent process’s entire virtual memory including the initialized Python interpreter, loaded modules, and constructed objects in memory. But fork does not copy the parent process’s threads. Thus locks (in memory) that in the parent process were held … Read more

how to exit a child process – _exit() vs. exit

You should definitely use _Exit(). exit() calls the functions you added with atexit() and deletes files created with tmpfile(). Since the parent process is really the one that wants these things done when it exists, you should call _Exit(), which does none of these. Notice _Exit() with a capital E. _exit(2) is probably not what … Read more