"The Linux Gazette...making Linux just a little more fun!"


(?) The Answer Guy (!)


By James T. Dennis,
LinuxCare, http://www.linuxcare.com/


(?) Programming Question about Regaining stdin/stdout

From Marco Mele on Wed, 22 Sep 1999

After a freopen() to redirect stdin or stdout, how to get back the stdin to the keyboard and the stdout to the screen?

(!) It sounds like a C/C++ programming question. I'm not a C programmer.
However, I might try keeping my stdin and stdout file handles and using an open() call on new file handles for my other file operations. Then you can perform the relaying yourself, and thus control what data goes to each of these streams.
I suppose you could save the value of your current TTY (using the coding equivalent of the 'tty'(1) command; grab its sources for an example) and re-open them later. (If this was a "do my homework" question your assignment is going to be pretty late, and probably wrong).

[ This message arrived while Jim was on a two week assignment in Japan... although he has begun to read into the backlog, there are likely to be a few more late answers coming your way, gentle readers. -- Heather ]


Copyright © 1999, James T. Dennis
Published in The Linux Gazette Issue 46 October 1999
HTML transformation by of Starshine Technical Services, http://www.starshine.org/


[ Answer Guy Current Index ] 1 2 3 5 5 6
7 8 9 10 11 12 [ Index of Past Answers ]


[ Table Of Contents ] [ Front Page ] [ Previous Section ] [ Linux Gazette FAQ ] [ Next Section ]