Relations between control characters, signals and terminal

signalsspecial charactersterminal

What are the relations between control characters and signals? Or are they unrelated?

Are control characters received by a terminal?

After a terminal receives a control character, is the terminal sending out a signal to a process one of the possible action of the terminal to the received control character?

For example,

in Linux, in a terminal, Ctrl+C will terminate a running foreground process. In ASCII, Ctrl+C is a control character which means " End of Text".

In ASCII, Ctrl+D is a control character which means end of transmission. Does the control character make the terminal send out some signal to some process?

Best Answer

The terminal driver (part of the operating system) establishes the relationship between special characters and signals. Your terminal settings, e.g., using stty, are what it uses to decide what (if anything) to do with characters that you type. You can reassign those special characters as needed with a few caveats:

  • only one special character per function
  • only single-byte characters are used

controlC and controlD are conventional: while a few applications may hardcode these values, the terminal driver does not require that.

The terminal driver is software, not part of your terminal. For some keyboards you may find different assignments of special characters more convenient than others (and for different operating systems, a few choices of the default values for the special characters may differ).

Further reading:

Related Question