1

The TTY subsystem contains the TTY driver, line discipline(s) and hardware drivers (keyboard driver, display driver). Let's say I use a virtual terminal/console. So, my current session uses ‍/dev/tty1 (TTY device 1). When I press Ctrl+Alt+F2, I open another session which now uses /dev/tty2 (TTY device 2).

So, who controls which /dev/ttyN is the active one?  Line discipline?

How about output from inactive /dev/ttyN?  Input from process attached to it cannot be output to line discipline because it is an inactive tty.  So, input from process will just be dropped?

Ron Vince
  • 1,442

1 Answers1

4

Without OP specifying a particular system, the advice has to be generic.

For a terminal emulator, the most common configuration uses pseudo-terminals. As a rule, those do not use the /dev/ttyXX naming convention:

  • Before Unix98, the BSD pseudo-terminal naming convention was predominant, using names such as /dev/ttypXX (master) and /dev/ptypXX (slave). You can see some variants in xterm's ptyx.h header.
  • With Unix98, some of the other variants were consolidated, and library interfaces provided to reduce the need for special device names in programs. The most common form allocates slave devices under /dev/pts.

In contrast, a /dev/ttyXX name usually refers to a (more or less) real console. With Linux, those names are virtual consoles, not related to pseudoterminals. A terminal emulator would not be connecting to those. But you can have active sessions on each of those virtual consoles.

Further reading:

Line discipline is a different aspect from "active connection". A terminal emulator does have to initialize the connection to use it, but once initialized, it will stay active until one end of the connection is dropped.

Further reading:

In regard to selecting a particular /dev/ttyXX device, you should look at a terminal server.

Thomas Dickey
  • 76,765