Nice post and exactly what I want! I'm using xterm to run shell program and I absolutely need to see the output of the program. I notice a strange behaviour of the subprocess module, when ever I try to run child process it hangs my parent window until I close or kill a child process. At the same time, running above script without input or output from child process resolve that issue but now I can not get termination signal 0. Maybe I am doing something wrong ? Or maybe it's subprocess issue. Can somebody help ?
import subprocess as sp
xl=sp.Popen("xterm -hold -e /usr/bin/python", shell=True, stderr=sp.PIPE, stdout=sp.PIPE)
pid = xl.pid
stdout_value, stderr_value= xl.communicate()
xlp=xl.poll()
failed = xl.returncode
print xlp, pid, failed