开发者

run a process in another terminal

I'm actually running a subprocess from a python program using Popen

proc= subprocess.Popen("xterm -e python script.py", shell=True, stdout=subproc开发者_运维技巧ess.PIPE, stderr=subprocess.PIPE)

And when this process is running on xterm, we can kill it using Ctrl+C, is there a way to send other signals using (Ctrl+Z and fg,...) to resume and continue the job? Another solution would be running this process in another terminal, without using xterm -e is this possible? Any other solution would be helpful. Thanks


You could do it programatically in psutil

import psutil
p = psutil.Pocesss(proc.pid)
p.suspend()
p.resume()


With Python2.6+

# send ctrl+c
popen.send_signal(signal.SIGINT)
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜