How can I get back to the interactive keyboard if stdin is redirected?

Q

I'm trying to write a program like ``more.'' How can I get back to the interactive keyboard if stdin is redirected?

✍: Guest

A

There is no portable way of doing this. Under Unix, you can open the special file /dev/tty. Under MS-DOS, you can try opening the ``file'' CON, or use routines or BIOS calls such as getch which may go to the keyboard whether or not input is redirected.

2015-09-29, 814👍, 0💬