I have this code:
subprocess.run(['perf', 'record', 'yes'], timeout=1)
This code kills the perf
subprocess after 1 second; however, its child yes
process is left running.
I expected that this code would behave similarly to running perf record yes
in a terminal and Ctrl+C'ing it after 1 second. When you do that, the Ctrl+C kills both perf
and yes
.
How can I write the code such that both the perf
child process and the yes
grandchild process are killed?