Problems redirecting STDOUT (NOT sys.stdout) to a pipe.

E

Elad

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top