19

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

Eg:

  • Ctrl+C - SIGINT
  • Ctrl+\ - SIGQUIT
  • 2
    The "keyboard" doesn't send any signals, the line discipline does. Find out what a line discipline is, then read man 1 stty. – Satō Katsura May 2 '17 at 6:09
  • @SatoKatsura The line discipline is kind of a keyboard driver. – Gilles May 2 '17 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. – Satō Katsura May 3 '17 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. – Gilles May 3 '17 at 11:32
21

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
  • Hmm, what about Ctrl-S and Ctrl-Q? Do you have a reference for this? – Tom Hale May 2 '17 at 7:39
  • 4
    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. – Johan Myréen May 2 '17 at 7:59
  • 1
    man stty | grep -C1 signal is one source for these three being the only signals generated by the terminal. – Tom Hale May 2 '17 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. – Satō Katsura May 2 '17 at 10:12
7

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
    ^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. – Satō Katsura May 2 '17 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.