• Ctrl+D is not some special exit magic … it just tells the terminal to flush the bytes you typed to the input of the reading programm
    • meaning the terminal does a write() syscall on the pipe that is stdin where the running programm is blocking on a read() syscall waiting for bytes to read
    • such a flushing is also done when the terminal gets an enter key event
      • and there is this special mode, where after every key a write call is issued … used for interactive terminal application
    • Ctrl+D is the hotkey to tell the terminal to do just that…
      • resulting for shells and similar interpreters when you haven’t typed anything in a write call of len 0 … therefore a read call that returns 0 … which is interpreted as a EOF = End Of File by most Unix or cli programms
    • rel: https://unix.stackexchange.com/a/483533