What typing ^D does on Unix (2009)
utcc.utoronto.ca
What typing ^D does on Unix (2009)
1–10 of 162 posts
Re: What typing ^D does on Unix (2009)
#2Re: What typing ^D does on Unix (2009)
#3Re: What typing ^D does on Unix (2009)
#4huh. That's really interesting. I assume ^L is handled in the tty driver as well?
$ stty -a | grep -F '^D'
intr = ^C; quit = ^\; erase = ^?; kill = ^U; eof = ^D; eol = ;
$ stty -a | grep -F '^L'
$
Your Ctrl-L clear-and-refresh command is implemented in Bash (or rather GNU readline).There is a "reprint" action, commonly bound to ^R:
$ stty -a | grep rprnt
eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;
It doesn't clear the screen; it just issues a newline and reprints the characters buffered so far. You can use stty to assign ^L to "rprnt".Re: What typing ^D does on Unix (2009)
#5Re: What typing ^D does on Unix (2009)
#6Re: What typing ^D does on Unix (2009)
#7Pressing enter then ~. will gracefully shutdown hung ssh sessions
Re: What typing ^D does on Unix (2009)
#8huh. That's really interesting. I assume ^L is handled in the tty driver as well?
In the C standard library, you just clearerr(stdin) and keep reading.
If a program takes two files as input and obeys the - convention for specifying stdin (or has some other way of opening the tty more than once), you can do:
$ program - -
then give it two inputs, each followed by [Ctrl-D][Enter]. For instance "cat - -".This sort of thing subtly breaks with some utilities. Try coaxing GNU diff to compare two pieces of tty input, haha.
Re: What typing ^D does on Unix (2009)
#9Pressing enter then ~. will gracefully shutdown hung ssh sessions
nice one, never seen that - always used ^D/exit
Re: What typing ^D does on Unix (2009)
#10Earlier quoted context omitted.
nice one, never seen that - always used ^D/exit
Those are yet more graceful -- for when the shell is responsive. Use ~. in cases where for some reason you cannot get access to the terminal anymore but remote sshd is responsive.