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 ]