开发者

Is there a way to pause a Python subprocess, specifically in Ubuntu?

开发者 https://www.devze.com 2023-03-06 06:50 出处:网络
I have a GUI based program where I need the user to be able to pause or resume a subprocess.For example, if I have:开发者_运维技巧

I have a GUI based program where I need the user to be able to pause or resume a subprocess. For example, if I have:

开发者_运维技巧
programID = subprocess.Popen("program_name"), shell=True)

Is there a way that I can pause or resume this? I read something about using SIGTERM but I didn't quite grasp it.


To pause the process, use

os.kill(programID.pid, signal.SIGSTOP)

To resume execution, use

os.kill(programID.pid, signal.SIGCONT)
0

精彩评论

暂无评论...
验证码 换一张
取 消