skip to Main Content

Ubuntu – Unable to pkill a subprocess

Consider: import subprocess import time def run_instance(): command = "sleep 30 >out 2>err &" subprocess.check_output(command, shell=True, start_new_session=True) def kill_instance(): print(subprocess.check_output(f"pgrep -f 30", shell=True)) subprocess.check_output(f"pkill -f 30", shell=True) run_instance() time.sleep(1) kill_instance() The output (run under Ubuntu) is: b'17483n17484n' Traceback (most recent…

VIEW QUESTION
Back To Top
Search