Redirecting stdout, and then getting it back

uunet!bria!mike uunet!bria!mike
Fri Feb 15 08:24:21 AEST 1991


In an article, berlioz.nsc.com!nelson (Taed Nelson) writes:
|
|We have a "shell" program which executes programs from within it using the
|  system()/spawn() call.  We wanted to trap these errors, so we freopen()ed
|  stdout and stderr to files that we could parse/show to the user from within
|  the "shell".  This part works fine.
|
|We also want to provide a "subshell" capability to get out to csh or DOS, but
|  clearly we want stdout and stderr to go back to the screen.  Unfortunately,
|  freopen() closed the original screen file, so we can't get output to go
|  there.

How about using /dev/tty, such as:

	freopen("/dev/tty","r",stdin);
	freopen("/dev/tty","w",stdout);
	freopen("/dev/tty","w",stderr);

|(Thanks!)

You're welcome.
-- 
Michael Stefanik                       | Opinions stated are not even my own.
Systems Engineer, Briareus Corporation | UUCP: ...!uunet!bria!mike
-------------------------------------------------------------------------------
technoignorami (tek'no-ig'no-ram`i) a group of individuals that are constantly
found to be saying things like "Well, it works on my DOS machine ..."



More information about the Comp.unix.questions mailing list