python - capturing stderr of subprocesses with their shell stdout alive
Question: Here are things I'm trying to do:

    
    
    -python process captures stderr of multiple subprocesses to watch the subprocesses
    -each subprocess runs on the separate window displaying stdout. 
    

When I use **Popen(_command_ ,stderr = _fp4tempfile_)**,

    
    
    (good) the python process can capture stderr of the subprocesses
    (bad ) the subprocess shells stop displaying stdout.
    

When I use **Popen(_command_)**,

    
    
    (good) each subprocess shells displays stdout (as well as stderr, which does not matter for me), 
    (bad ) the python process cannot capture stderr. 
    

I want both "good"s. What can I do for this? Thanks in advance. (currently,
I'm using python3.2 developing in windows7)

Here's the parent process source written in python:

    
    
    import os,subprocess
    import time
    fpws = []
    fprs = []
    
    def run_command(command):
        <specifying a file to write -- skipped>
        fpw = open(ftempname,'w')
        fpr = open(ftempname,'r')
        #cmd_redirect = "%s 2>%s" % (command,ftempname)#didnt do anything
        #starting a sub-program:
        pp = subprocess.Popen(command,stderr = fpw) #++
        #pp = subprocess.Popen(command)             #@@
        fpws.append(fpw)
        fprs.append(fpr)    
    
    def watch_program():
        while True: #running forever for simplfication
            for fpr in  fprs:
                outchunk = fpr.read()
                <do something for subprocesses stderr -- skipped>
                time.sleep(1.0)
    
    if __name__ == '__main__':
        cmd1 = '(path to program1)'
        cmd2 = '(path to program2)'
        run_command(cmd1)  #kicking cmd1
        run_command(cmd2)  #kicking cmd2
        watch_program()          #hearing stderr msg from the other process
    

Note: in the subprocess side, fflush(stdout) and fflush(stderr) are called as
needed.


Answer: Haven't tested this, but can you do

    
    
    import sys
    
    pp = subprocess.Popen(command, stderr = fpw, stdout = sys.stdout)
    

