Problems redirecting STDOUT (NOT sys.stdout) to a pipe.
Elad
elad.gerson at gmail.com
Sun Mar 19 08:30:10 EST 2006
Hello All,
I am trying to capture some printf's from a C function called by
python.
<Working under winxp>
I have tried to following:
STDOUT = 1 # stdout fd
(re, we) = os.pipe() # Create re / write handlers
dup2(we, STDOUT) # override system's stdout, should dup first and
restore later..
call_my_hello_world() # if stdout is not overriden will print hello
world on console screen
x = os.read(re, 11)
sadly, x = '' after the code is executed.
help ? :-)
Thanks,
Elad.
More information about the Python-list
mailing list