On Wed, Sep 1, 2010 at 8:12 PM, Astan Chee <astan.c...@al.com.au> wrote: > Hi, > I have a piece of code that looks like this: > > import subprocess > retcode = subprocess.call(["java","test","string"]) > print "Exited with retcode " + str(retcode) > > What I'm trying to do (and wondering if its possible) is to make sure that > any children (and any descendants) of this process is killed when the main > java process is killed (or dies). > How do I do this in windows, linux and OSX?
Something /roughly/ like: import os import psutil # http://code.google.com/p/psutil/ # your piece of code goes here myself = os.getpid() for proc in psutil.process_iter(): if proc.ppid == myself: proc.kill() Cheers, Chris -- http://blog.rebertia.com -- http://mail.python.org/mailman/listinfo/python-list