I\'m trying to write a python program that is able to interact with other programs. That means sending stdin and receiving stdout data. I cannot use pexpect (although it definit
When your child process exits - your parent process gets SIGCHLD signal. By default this signal is ignored but you can intercept it:
import sys
import signal
def handler(signum, frame):
print 'Child has exited!'
sys.exit(0)
signal.signal(signal.SIGCHLD, handler)
The signal should also break the blocking syscall to 'select' or 'read' (or whatever you are in) and let you do whatever you have to (cleanup, exit, etc.) in handler function.