If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!
read the transcript!
quitting a terminal program isn’t always easy
Illustration of a stick figure with short curly hair. They look distressed and have an exclamation mark above their head.
person (thinking): “I pressed Ctrl-C
17 times and NOTHING HAPPENED”
ways to quit
Ctrl-C
- the defaultCtrl-D
- if you’re at a prompt in aREPL >>>
q
- if it’s a full screen programCtrl-\
- sometimes works ifCtrl-C
doesn’tkill -9
- the last resort
how Ctrl-D
works
programs that read input will usually have some code like this:
text = read_line()
if (text == EOF) {
exit()
}
Ctrl-D
is how you send an EOF to the program (“I’m done!”)
important: Ctrl-D
ONLY works if you press it on an empty line
how Ctrl-C
works *
*
unless your program is in “raw mode”, we’ll talk about that later
person, smiling: “ctrl-C
“
terminal emulator, represented by a box with a dollar sign: “ok, C is the 3rd letter of the alphabet, I’ll write 3 to the tty”
OS terminal driver, represented by a box labelled “OS”: ah, a 3, that means I should send the SIGINT
signal to the current program
program, represented by a box with a smiley face: ooh, a SIGINT
, I will [shutdown gracefully, immediately exit, ignore it, stop a subtask, etc]
*
unless your program is in “raw mode”, we’ll talk about that later
some programs have weird quitting incantations
for example every text editor (vim, nano, emacs, etc) has its own completely unique way to quit
Saturday Morning Comics!
Want another comic like this in your email every Saturday? Sign up here!