News for hackers. Stuff that matters.
Re:Getting the ^D by donatj on Monday April 10, 2023 @01:40AM (#35509492)
Hmm, my assumption up to now had honestly been that ^D was just the shortcut for a NULL byte, 0x0 and everything just assumed it’d reached the end of the stream.

Sending a special EOT 0x4 that gets special terminal handling feels just a little less… elegant… than what I had imagined.

Re:Getting the ^D by wruza on Monday April 10, 2023 @02:06AM (#35509607)
Please look at ascii table to see why ctrl-{key} sends a corresponding control code and why the modifier is called “control”: https://www.commfront.com/pages/ascii-chart
Re:Getting the ^D by donatj on Monday April 10, 2023 @02:10AM (#35509625)
The article explained it well enough. Makes sense, I just was unaware. From that chart though then could ^` generate a NULL byte?
Re:Getting the ^D by proto_lambda on Monday April 10, 2023 @02:58AM (#35509834)
The chart also lists the control key combination for each control byte, for NUL, it's C-@.
Re:Getting the ^D by jwilk on Monday April 10, 2023 @06:17AM (#35510765)
^` works too.
Re:Getting the ^D by tuukkah on Monday April 10, 2023 @02:15AM (#35509652)
If EOF was a character, you couldn't process (binary) streams that contain the character.

^@ produces the NUL character.

Re:Getting the ^D by 1vuio0pswjnm7 on Monday April 10, 2023 @04:02AM (#35510155)
"I am curious now, would it be possible to make the keyboard generate a NULL byte either by existing keyboard shortcut or custom hardware - and how would the system handle it?"

Not sure I understand the point of the experiment, but in NetBSD kernel one can remap the keyboard, e.g., set a key to 0x00. How to do this in Linux kernel is a question for reader.

https://ftp.netbsd.org/pub/NetBSD/NetBSD-current/src/sys/dev...

Re:Getting the ^D by layer8 on Monday April 10, 2023 @08:13AM (#35511389)
The NUL byte has no special meaning in file I/O, or the terminal. (Historically, the only special meaning was as a no-op character that does nothing.) The convention of using NUL as a termination character only exists for in-memory strings in C, and has no connection to file I/O.