I'm running two command through multprocessing.Process
and os.system
. One of these commands is adb logcat
which produces logs, until SIGTERM or CTRL+C. How to terminate os.system command inside Process?
Sample code:
import time
import os
from multiprocessing import Process
def run_instrument():
while True:
time.sleep(3)
def run_logcat():
logcat_cmd = "adb logcat -s Engine:I"
os.system(logcat_cmd)
logcat_proc = Process(target=run_logcat)
logcat_proc.start()
inference_proc = Process(target=run_instrument)
inference_proc.start()
inference_proc.join(5)
logcat_proc.terminate()
After call terminate
, adb logcat
is still present in system via ps aux
.