Use subprocess.Popen()instead subprocess.call(). For instance:
import subprocess
my_process = subprocess.Popen(['ls', '-l'])
To complete the children:
my_process.kill()
To capture the kill signal, you can do something like this:
import signal
import sys
def signal_handler(signal, frame):
sys.exit(0)
signal.signal(signal.SIGINT, signal_handler)
source
share