[an error occurred while processing this directive] Node:Input EOF, Next:, Previous:CGI programs, Up:Miscellany

22.29 Why Do I Get EOF From stdin?

Q: Whenever I run my program, which reads stdin, from RHIDE or Bash, it gets EOF indication immediately, without any input being typed! This program runs okay from the DOS prompt, so something must be wrong with Bash and RHIDE, yes?

A: This is a known (mis-)behavior of DOS: to clear the EOF condition of the console device, you need to write something to it. If during some previous invocation of a program you typed Ctrl-<Z>, the resulting EOF condition will stick until something is written to the console device. When the program is run from the DOS prompt, that "something" is the prompt string printed by COMMAND.COM. However, RHIDE doesn't print any prompt, and Bash prints its prompt via the BIOS. So, as soon as you type Ctrl-<Z>, the console device is stuck in the EOF condition, and all subsequent invocations of programs that read standard input immediately get receive EOF and exit. (This problem is not specific to DJGPP: Norton Commander also exhibits it.)

A work-around is to output something to stdout or stderr (assuming they both are connected to the console device).


[an error occurred while processing this directive]