On Jun 5, 2007, at 4:17 PM, Thomas Dybdahl Ahle wrote: > Den Tue, 05 Jun 2007 15:46:39 -0500 skrev Michael Bentley: > >> But actually *that* is an orphan process. When a parent process dies >> and the child continues to run, the child becomes an orphan and is >> adopted by init. Orphan processes can be cleaned up on most >> Unices with >> 'init q' (or something very similar). > > Is it not possible to tell python that this process should not be > adopted > by init, but die with its parrent? > Just like terminals seem to do it..
Well, the way you posed the original question: > from subprocess import Popen > popen = Popen(["ping", "google.com"]) > from time import sleep > sleep(100) is really what adoption by init is designed to handle. Here you've created a child but have not waited for its return value. Like a good adoptive parent, init will wait(2) for the child. I think if you really looked into it you'd find that the terminal had called wait(2) before it was killed. Similarly, if you start a long- running subprocess in python and wait for it to return -- killing the parent will slaughter the child as well. hth, Michael --- Let the wookie win. -- http://mail.python.org/mailman/listinfo/python-list