[cs631apue] Suspend stdin, wait for another user input
Jan Schaumann
jschauma at stevens.edu
Sat Dec 7 09:09:36 EST 2013
Tejas Nadkarni <tnadkarn at stevens.edu> wrote:
> FYI...I tried using this and didn't get it to work but there is a way to do
> this using freopen, dup, dup2 by saving stdin,stdout then redirecting to
> dev/tty and then restoring them back. This method seems to work the best
> for me. Thanks.
If this works, then that's fine, but it shouldn't be necessary.
You should be able to prompt for a password and read from /dev/tty and
then read data from STDIN_FILENO without having to dup2(2) or reopen any
file descriptors.
You may also want to take a look at the getpass(3) and readpassphrase(3)
functions.
-Jan
More information about the cs631apue
mailing list