有没有办法暂停Python子进程,特别是在Ubuntu中?

Cob*_*tez 2 python resume subprocess popen

我有一个基于GUI的程序,我需要用户能够暂停或恢复子进程.例如,如果我有:

programID = subprocess.Popen("program_name"), shell=True)
Run Code Online (Sandbox Code Playgroud)

有没有办法可以暂停或恢复这个?我读了一些关于使用SIGTERM的内容,但我并没有完全掌握它.

Sve*_*ach 6

要暂停该过程,请使用

os.kill(programID.pid, signal.SIGSTOP)
Run Code Online (Sandbox Code Playgroud)

要恢复执行,请使用

os.kill(programID.pid, signal.SIGCONT)
Run Code Online (Sandbox Code Playgroud)