1

I have two subprocesses as I showed below

cmd1='arecord -d 0 -f cd -t wav test.wav'
cmd2='raspivid -o video.h264 -fps 25 -t 0'

pro1 = subprocess.Popen(cmd1, shell=True)
pro2 = subprocess.Popen(cmd2, shell=True)

I want to record audio and video at the same time with raspberry pi. From now on I can start both programs but I cannot stop these programs. Can anybody help me?

Or any idea for doing by simple way this process?

2 Answers2

2

From the docs:

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.

New in version 2.6.

Popen.kill() Kills the child. On Posix OSs the function sends SIGKILL to the child. On Windows kill() is an alias for terminate().

Cameron Sima
  • 5,086
  • 6
  • 28
  • 47
0

The documentation for Python's subprocess module includes a description of Popen.terminate() and Popen.kill().

inquiryqueue
  • 957
  • 6
  • 15