Ctrl-D in input

Andrew Schorr beareq!quants4!schorr at wheaties.ai.mit.edu
Wed Feb 15 09:54:05 AEST 1989


As usual, a question that is probably trivial for those who know the
answer:

If some irresponsible user types a Ctrl-D to your program, how can you
continue as if this had never been typed?

Currently, I do nothing.  Unfortunately, this makes my program go haywire
(it keeps detecting an EOF condition on stdin).  If I close stdin, there
is no problem, but the user can no longer interact with the program.

Thanks in advance,
Andrew Schorr <beareq!schorr at wheaties.ai.mit.edu>

[[ Try "clearerr(stdin)".  That should clear the EOF condition and allow
you to continue reading from the stream.  Of course you have to be careful
to make sure that you aren't really reading from a file.  You might get
stuck in a infinite loop.  Read ferror(3S).  --wnl ]]



More information about the Comp.sys.sun mailing list