I created a channel and I used dup2 () to rewrite streams 1 and 2 (stdout and stderr) to these channels.
Now I want to use fprintf to write to stream 1 or 2, but my program does not seem to get anything on the other side of the pipe. I tried using printf (), but I'm not sure if this is written to stdout or stream 1 by default. If it writes to stream 1, I think its problem is somewhere deeper in my code.
Essentially, I ask, given the int representing the stream, how can I get FILE * suitable for use in fprintf ()?
c printf pipe system
samoz
source share