I am executing a bash script in Python using the tempfile and subprocess like so:
with tempfile.NamedTemporaryFile() as scriptfile:
scriptfile.write(teststr)
scriptfile.flush()
subprocess.call(['/bin/bash', scriptfile.name])
Here, teststr has the entire bash script within it.
My question is, once it starts to execute, it doesn't capture keyboard interrupts like Ctrl+c and ctrl+z.
Is there anyway to interrupt the execution of the script once it has begun?
SIGINT...signal(SIGINT, SIG_IGN)and enters infinite loop, signal is successfully delivered to Python parent (as it should be: entire process group is affected) where it raises an appropriate exception. EDIT: Oh, never mind: the child keeps running and that is the problem, probably.