How to kill a subprocess in python
问题 I have code which runs a webcamera on a linux pc using the gst-launch command. When I kill the process, the webcamera window does not turn off, but the program stops running. I want the webcamera window also to be closed. Can you help me on this? import subprocess import time import os import signal cmd = "gst-launch-1.0 -v v4l2src ! video/x-raw,format=YUY2 ! videoconvert ! autovideosink" process = subprocess.Popen(cmd, shell = True) time.sleep(5) #print(subprocess.Popen.pid) #process