3 ms·
This really helps me understand how read() works as I am currently learning C programming. Didn't know that ctrl+D still sent everything before it in the buffer
by rubatuga 8y ago
This really helps me understand how read() works as I am currently learning C programming. Didn't know that ctrl+D still sent everything before it in the buffer to the read call, and that a read of length zero and EOF was the same thing.
- majewsky 8y agoCtrl-D is maybe the hardest part of TTYs to emulate if you want to bypass the accumulated legacy of the kernel-level TTY device API. It's very easy to make read() return 0 forever, but it's next-to-impossible to make read() return 0 exactly once, except for TTY slaves.