News for hackers. Stuff that matters.
Re:Most Important Linux Commands Cheatsheet by thiagocsf on Friday January 14, 2022 @06:59AM (#29933412)
Pedantic note about ctrl+d: it doesn’t mean logout. It sends and EOF character.

Said EOF is honoured by your TTY, which closes the FD this ending the session.

You can see this by typing `cat -` and ending it with ctrl+d. The windows equivalent is ctrl+z.

Re:Most Important Linux Commands Cheatsheet by gnubison on Saturday January 15, 2022 @12:39AM (#29943884)
Pedantic-er note: ^D isn’t necessarily the VEOF character — you can change it with tcsetattr() after modifying termiosp->c_cc[VINTR] or by using stty(1). And it doesn’t send an “EOF character” (EOF is a condition/convention more than a character). All it does is make read(2) return immediately with whatever data is currently in the line buffer. You can try it now:

    $ cat
    something^Dsomething^D
    $ cat
VEOF causes the tty driver (tty(4)) to send “something” to cat immediately; and cat echoes that back out to the terminal as intended.

If there’s nothing in the line-buffer (because you pressed VEOF at the start of the line) then read(2) returns 0, which is interpreted as an end-of-file condition by your libc in fread() and friends.

You can checkout OpenBSD’s termios(4) for a more detailed explanation :)