Skip to Content
Navigation:

A stick figure smiling

If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
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 default
  • Ctrl-D - if you’re at a prompt in a REPL >>>
  • q - if it’s a full screen program
  • Ctrl-\ - sometimes works if Ctrl-C doesn’t
  • kill -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!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)