Killing A Subprocess Exits Python Program
def playvid(self): proc1 = subprocess.Popen('gst-launch-1.0 videotestsrc ! autovideosink', shell=True) time.sleep(3) os.killpg(os.getpgid(proc1.pid),signal.SIGTERM) Th
Solution 1:
If you read the documentation for subprocess there are several methods to choose from:
Popen.send_signal(signal)
Sends the signal signal to the child.
On Windows, SIGTERM is an alias for terminate().
Popen.terminate()
Stop the child. On Posix OSs the method sends SIGTERM to the child. On Windows the Win32 API function TerminateProcess() is called to stop the child.
Popen.kill()
Kills the child. On Posix OSs the function sends SIGKILL to the child. On Windows kill() is an alias for terminate().
I would use:
proc1.terminate()
Post a Comment for "Killing A Subprocess Exits Python Program"