On Linux, how does the X server establish a relationship with a particular tty (such as tty7) so that the X server can receive input and draw on the screen only when that tty is in the foreground? How is this enforced?

(I previously posted this question in the form shown below on Stack Overflow, where it was closed.)

I have a few questions about what it means when one says "the X server runs on /dev/tty7". I made a few guesses as to how it works, and I'm hoping someone can tell me whether the following statements are true or false.

  • /dev/tty7 is usually the controlling terminal for Xorg.
  • Even though tty7 is the controlling terminal for Xorg, it does not "control" Xorg in any meaningful way.
  • Xorg receives keyboard and mouse input directly by polling /dev/input/... or something like that, and not by reading from /dev/tty7. Nevertheless, /dev/tty7 also receives keystrokes, which you can see (for instance) by running "xxd -p /dev/tty7" in a terminal emulator.
  • Xorg draws on the screen using some hardware-specific interface, such as some device file that the driver creates, or an I/O mapped region of memory, and not by writing to /dev/tty7.
  • When Xorg sets the video mode, the tty driver automatically stops drawing on the screen. That's why, when you press a key or echo a string to /dev/tty7, you don't see it appear on the screen.
  • Xorg receives keyboard and mouse input via /dev/events even when tty7 is in the background, but it ignores it unless tty7 is in the foreground.
  • Whatever Xorg draws on the screen only becomes visible on the monitor when tty7 is in the foreground.
  • When Xorg initializes the video (setting video mode and so on), it is because tty7 is in the foreground that the settings take effect on tty7 and no other terminal.

Your Answer

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

Browse other questions tagged or ask your own question.