我想使用 2 个函数自动从串口捕获日志:
1) 触发开始捕获
2) 触发停止
第一次看起来像
def start_capture_output():
file = '/home/test/Desktop/log.txt'
os.system('touch %s' % file)
os.system('chmod +rwx %s' % file)
os.system('cat </dev/ttyUSB0>%s' % file)
它有效,但我想知道如何在不手动按 Ctrl+C 的情况下停止此过程
最佳答案
如果你用
生成进程child = subprocess.Popen("command")
然后就可以调用了
child.terminate()
child.kill()
关于python - 如何用 Python 杀死 Linux 进程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34949019/