Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

dup, dup2, and all that

1 view
Skip to first unread message

John E. Davis

unread,
Mar 9, 1993, 1:12:13 AM3/9/93
to
Hi,

I am writing a program that takes input from the user via stdin. In
addition, the program could take input from a file if stdin has been
redirected. I detect this using `isatty'. If the program has been started
as:

% ./a.out < input_file

after reading lines from the input file (redirected stdin), how do I redirect
stdin to what it was before redirection? This way I can take more input from
the user and any child processes will behave the same independent of whether I
typed:

% ./a.out
or
% ./a.out < input_file

I suspect it has something to do with dup, dup2, freopen, etc... but the man
pages are not too clear on this.

Thanks,
--
_____________
#___/John E. Davis\_________________________________________________________
#
# internet: da...@amy.tch.harvard.edu
# bitnet: davis@ohstpy
# office: 617-735-6746
#

0 new messages