o.O
I always tought the right way is CTRL+D.
o.O
I always tought the right way is CTRL+D.
https://github.com/MariaDB/server/pull/703
Instead, Ctrl+D is the way to ask the TTY driver to pass the program an EOF instead of input in response to its next read(2) call to its stdin. It's the same signal that the program would receive if you had been piping input into the program from a file, and that file reached the end. Thus, any CLI program built to handle being piped into, will "automatically" support Ctrl+D as a way to quit out of it.
> VEOF (004, EOT, Ctrl-D): End-of-file character (EOF). More precisely: this character causes the pending tty buffer to be sent to the waiting user program without waiting for end-of-line. If it is the first character of the line, the read(2) in the user program returns 0, which signifies end-of-file. Recognized when ICANON is set, and then not passed as input.
In other words, most programs that exit upon Ctrl+D never see the Ctrl+D, they see an empty result from read() on stdin and interpret that as end-of-file. However, that only works when the tty buffer is empty. Try this: On a Unix shell, run `cat`, type something without pressing Enter, then press Ctrl-D instead.
A couple minutes into a ten minute task someone goes whups I should have backgrounded that and they CTRL-C, up arrow, & and enter, and I say something like, “dude... we need to talk about CTRL-Z bg”