Amy
Amy

Reputation: 1

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=subprocess.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

Upvotes: 0

Views: 1018

Answers (2)

Mark
Mark

Reputation: 108567

With Python2.6+

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

Upvotes: 0

highBandWidth
highBandWidth

Reputation: 17306

You could do it programatically in psutil

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

Upvotes: 1

Related Questions