python - obtaining pid of child process -


i using python's multiprocessing module spawn new process

as follows :

import multiprocessing import os d = multiprocessing.process(target=os.system,args=('iostat 2 > a.txt',)) d.start() 

i want obtain pid of iostat command or command executed using multiprocessing module

when execute :

 d.pid  

it gives me pid of subshell in command running .

any valuable .

thanks in advance

similar @rakslice, can use psutil:

import signal, psutil def kill_child_processes(parent_pid, sig=signal.sigterm):     try:       parent = psutil.process(parent_pid)     except psutil.nosuchprocess:       return     children = parent.children(recursive=true)     process in children:       process.send_signal(sig) 

Comments

Popular posts from this blog

c++ - How do I get a multi line tooltip in MFC -

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -