112

Where can I find a complete list of the keyboard combinations which send signals in Linux?

Eg:

  • Ctrl+C - SIGINT
  • Ctrl+\ - SIGQUIT
4
  • 6
    The "keyboard" doesn't send any signals, the line discipline does. Find out what a line discipline is, then read man 1 stty. Commented May 2, 2017 at 6:09
  • @SatoKatsura The line discipline is kind of a keyboard driver. Commented May 2, 2017 at 21:50
  • @Gilles Not really. The keyboard driver deals with scancodes and the like. The line discipline is a sort of higher level glue that gives the application an unified view over many other things, like modem lines, USB-to-serial adapters, HID devices, etc. Commented May 3, 2017 at 5:29
  • @SatoKatsura It's a part of the operating system that sits beween the application and the keyboard. In other words, it's part of the keyboard driver. With a hardware terminal (like a vt100), it's the only transformation of keyboard input that's done by the computer as opposed to the terminal itself. Commented May 3, 2017 at 11:32

2 Answers 2

89

The Linux N_TTY line discipline only sends three different signals: SIGINT, SIGQUIT, and SIGTSTP. By default the following control characters produce the signals:

  • Ctrl+C - SIGINT
  • Ctrl+\ - SIGQUIT
  • Ctrl+Z - SIGTSTP
4
  • 3
    Hmm, what about Ctrl-S and Ctrl-Q? Do you have a reference for this?
    – Tom Hale
    Commented May 2, 2017 at 7:39
  • 15
    No signals are involved when you press Ctrl-S or Ctrl-Q. They just throttle the flow of characters, preventing them from reaching the consuming process. Eventually, when buffers fill up, the producing process will block in the write system call until Ctrl-Q unthrottles the flow. Note that it is normal for the call to write can block even without Ctrl-S: if the receiving process is slow to consume the data sent to it, e.g. because it is spending most of its time processing already received data instead of reading new data. Commented May 2, 2017 at 7:59
  • 2
    man stty | grep -C1 signal is one source for these three being the only signals generated by the terminal.
    – Tom Hale
    Commented May 2, 2017 at 9:17
  • @TomHale ... Except "modem control signals" are electrical signals. :) Really, SIGINT, SIGQUIT and SIGTSTP are the only "usual" signals sent by the line discipline. On BSD you also have things like SIGINFO, but that's not standard. Commented May 2, 2017 at 10:12
33

You can use stty to check or change the characters that generate signals.

$ stty -a | grep -Ewoe '(intr|quit|susp) = [^;]+'
intr = ^C
quit = ^\
susp = ^Z

intr (interrupt) generates SIGINT, quit generates SIGQUIT, susp (suspend) generates SIGTSTP. stty -a will also show things like start = ^Q; stop = ^S; and erase = ^? (backspace), which don't send signals but affect the terminal layer otherwise.

Plain stty will show the non-default settings and e.g. stty intr ^Q would change the interrupt character to ^Q instead of ^C.

I think ^L (form feed, new page) is not a terminal feature, but a character often used by applications to ask for a redraw the view, rechecking the window size at the same time.

1
  • 3
    ^L has a different meaning for different applications. In most curses-based applications (such as vim, less, mutt, mc, etc.) it forces a complete redraw (thus re-checking the window size), but in shells (bash etc.) it just clears the screen. There is no SIGWINCH involved. Commented May 2, 2017 at 10:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .