Passing End of Transmission (Ctrl + D) character in Eclipse CDT console
It seems to be a not yet resolved bug: bug 159803 (resolved in September 2015, for CDT 9.0)
Since Eclipse 3.1 it is possible to signal
EOF
(using CTRL + D/Z - bindable in key preferences) in console view, and I tested this successfully with Eclipse 3.2.1 using a simple Java app.
CDT on the other hand will not recognizeEOF
when in console view.
There is one exception though.If I run a C/C++ Local App and uncheck "
Connect process input & output to a terminal
" in the main configuration tab, the console view will recognizeEOF
.However, this change does not affect the console view when in the Debug perspective. So while debugging it is still impossible for me to send an
EOF
signal to the running application.
Even though it is considered "resolved", this comment shows the issue persists.
Update 4 years later (Dec 2014), Fernando Gonzalez-Sanchez mentions in the comments:
Workaround checkbox no longer available in UI.
Problem still happening in OpenSUSE 12 & Eclipse CDT Luna 4.4.1.
Update March 2015:
Muhammad Annaqeeb mentions in the comments:
There is a new workaround mentioned in the bug page:
In Kepler 4.3 eclipse.buildId=4.3.0.M20130911-1000 on Linux the problem still exists in the Java console. I found the following workaround:
"If you leave the console to focus on another view, and then refocus on the console, then Ctrl-D (EOF) works as expected."
Send an EOF in Eclipse's debugger console
It's a bug, see here:
Passing End of Transmission (Ctrl + D) character in Eclipse CDT console
Can we write an EOF character ourselves?
There is no EOF character. EOF by definition "is unequal to any valid character code". Often it is -1. It is not written into the file at any point.
There is a historical EOF character value (CTRL+Z) in DOS, but it is obsolete these days.
To answer the follow-up question of Apoorv: The OS never uses the file data to determine file length (files are not 'null terminated' in any way). So you cannot trick the OS. Perhaps old, stupid programs won't read after CTRL+Z character. I wouldn't assume that any Windows application (even Notepad) would do that. My guess is that it would be easier to trick them with a null (\0
) character.
Related Topics
Defining Global Constant in C++
Can Openssl on Windows Use the System Certificate Store
Can't Overload Operator<< as Member Function
How to Change the Variable to Which a C++ Reference Refers
Cleaning Up an Stl List/Vector of Pointers
Netbeans 7.2 Shows "Unable to Resolve Identifier" , Although Build Is Successful
Why How to Use 'Std::Move' on a 'Const' Object
How to Find All the Functions Exposed by a Dll
Fatal Error Lnk1104: Cannot Open File 'Libboost_System-Vc110-Mt-Gd-1_51.Lib'
Generate Sha Hash in C++ Using Openssl Library
What Destructors Are Run When the Constructor Throws an Exception
Segmentation Fault at Glgenvertexarrays( 1, &Vao );
Deprecated Conversion from String Literal to 'Char*'
C++ Error: '_Mm_Sin_Ps' Was Not Declared in This Scope
Does the C++ Standard Specify Anything on the Representation of Floating Point Numbers