[Tutor] Controlling a process and then killing it

Hugo González Monteverde hugonz-lists at h-lab.net
Sat Oct 23 19:43:20 CEST 2004


Hi Tutors,

Is there any way to get the process id of something you run using popen*???

I'm writing a front end to MPlayer, and I'm lucky that MPlayer lets me 
send a "quit" command to it... If I did not have this, how could I get 
the process ID in order to send a SIGTERM later on and (maybe) reap the 
children??

mystdin, mystdout = os.popen2(myprogram)
time.sleep (20)
#I'd like to kill the process here

Is this available as any attribute in  any module? I'm aware of the 
functions in the sys module, but they will give me info only if the 
popen call throws an exception...

Hugo


More information about the Tutor mailing list