[python-win32] how to find / kill child process ?

Julio Canto jcanto at hispasec.com
Mon Sep 7 10:27:08 CEST 2009


Stef Mientki escribió:
> hello,
>
> I start a number of python files with subproces.Popen
> and keep a list of these processes.
> Something like this:
>
>    arguments = [ 'python', self.Source_File ]
>    Proces = subprocess.Popen ( arguments,
>                            cwd   = source_path ,
>                            shell =  ( os.name == 'nt') )
>
>    self.Desktop_Processes.append ( Proces )
>
> Now when I close my program,
> I also want to kill all the processes this program has launched.
>
> The processes that I've started,
> always consists of a command window (invisible),
> and Python as a child process of that command window.
>
> Now killing the the processes in my list,
> only kills the command windows
> and not the python python process.
>
> So how can I kill a process and all it's child processes ?
>
> t
You can check the process parent id, and create the process tree so you
can kill them all.

-- 
Regards,

Julio Canto | VirusTotal.com | Hispasec Sistemas Lab | Tlf: +34.902.161.025
| Fax: +34.952.028.694 | PGP Key ID: EF618D2B | jcanto at hispasec.com



More information about the python-win32 mailing list