Vizible’s Blog

Python – How to kill subprocess.Popen

Posted in Programming, Python by wearetherock on August 3, 2009

Code
=====================================
import subprocess as subp
import win32api
proc = subp.Popen('C:\\KXBMC\cshape-wii\\WiiSignal.exe', stdin=subp.PIPE, stdout=subp.PIPE, bufsize=0)
... do somting here
# kill process
win32api.TerminateProcess(int(self.proc._handle), -1)

~

Notice
=====================================
It not work if you set shell = True
proc = subp.Popen('C:\\KXBMC\cshape-wii\\WiiSignal.exe', stdin=subp.PIPE, stdout=subp.PIPE, bufsize=0, shell = True)
~
Reference : http://code.activestate.com/recipes/347462/
~

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: