Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm working on a project to produce a shell in Python, and one important feature is the ability to pause and background a running subprocess. However the only methods I've found of pausing the subprocess appear to kill it instantly, so I can't resume it later. Our group has tried excepting KeyboardInterrupt:

try:
    process = subprocess.Popen(processName)
    process.communicate()
except KeyboardInterrupt:
    print "control character pressed"

and also using signals:

def signal_handler(signal,frame):
    print 'control character pressed'

signal.signal(signal.SIGINT, signal_handler)
process.communicate()

Another issue is that both of these only work when Ctrl-C is pressed, nothing else has any effect (I imagine this is why the subprocesses are being killed).

share|improve this question
    
what do you mean by "pause". Is it "suspend" as with SIGSTOP/SIGCONT signals (see Jobs and sessions)? –  J.F. Sebastian Nov 11 '13 at 20:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.