I am trying to debug a program that needs to read EOF as an input.
However, when I hit Control-D to send EOF when the program is running in GDB, GDB traps the EOF and does not pass it to the application.
How can I cause gdb to send the EOF to the application?
GDB does not do any such thing.
In a normal (all-stop) mode, either the application, or the GDB has control of the terminal, but not both.
If the application is reading the terminal input, then Control-D will cause it to read
EOF, and GDB will not interfere with that.If you are looking at the
(gdb)prompt, then the application is not reading the input — it is stopped — and sending Control-D will indeed sendEOFto GDB. Don’t do that.Example:
Update:
That’s exactly what is supposed to have happened (
readreturning 0 means that you’ve reached end of file). If you are expecting the application to read magicalEOFsymbol, your expectation is wrong — there is no such symbol.