0
root 717  2.0  3.2 1038344 263604 tty7   Rsl+ /usr/lib/xorg/Xorg -core :0 -seat seat0 -auth /var/run/lightdm/root/:0 -nolisten tcp vt7 -novtswitch

Is it correct that the X server process is running the program named Xorg? (So I can be assured that I have found the X server process.)

It is a server, so why does it still have a controlling terminal (tty7)? Why can't it give up a controlling terminal and become a daemon?

Thanks.

  • It can be a daemon without tty, then it's called vnc. – Ipor Sircer Dec 19 '18 at 18:11
  • How do you start X server as vnc? Does vnc use the same X server process as the X server process that I am interacting directly and locally? Or does vnc creates a daemon X server, separately from the one that I am using directly and locally? – Tim Dec 19 '18 at 18:16
  • X is a very special server. Rare are the servers whose resources are a keyboard, a mouse and a display... – jlliagre Dec 19 '18 at 20:41
  • @jlliagre Could you rephrase "Rare are the servers whose resources are a keyboard, a mouse and a display.."? – Tim Dec 19 '18 at 20:56
  • Sorry if wasn't clear. Usually, you are on the client side with a PC, laptop, or phone and you connect to remote servers which are daemons and whose resources are often databases or similar. The roles are reversed with X11, where the server runs on your desktop and its resources are what typically are on the client side, like a screen, a keyboard and a mouse. The last three pieces of hardware are close to what was once called a tty. – jlliagre Dec 19 '18 at 21:38
4

The X11 server does not need any old terminal device. It specifically needs a kernel virtual terminal device.

This is because it isn't using the terminal for general terminal I/O. It is using the terminal as a way of negotiating sharing I/O devices between it and the terminal emulator program that is built into the kernel. Using a protocol that is specific to kernel virtual terminal devices, which involves ioctl()s that only that type of device understands and sending signals to processes, it can negotiate when it is in charge of the display and Human Input Devices (HIDs) and when the kernel built-in terminal emulator program is.

(On Linux, this is the primary use of the KVT, with I/O routed through other devices entirely, and it being the controlling terminal is almost, but not quite, a side effect of fact that the X11 server opens the KVT device in a session that has no controlling terminal. On the BSDs, things are more complex, as the KVT device is also a way of accessing the framebuffer and HID input, albeit not as good a one as accessing the underlying USB HIDs if they are USB. However, on FreeBSD at least Xorg does not end up with the KVT as its controlling terminal in the first place, because on FreeBSD simply opening a terminal device never automatically makes it one's controlling terminal, and the question is moot because the Xorg process actually does not have a controlling terminal in normal operation.)

If the kernel's built-in terminal emulator is not using a particular display device or HID, which can be arranged with some effort (in ways that are well beyond the scope of this answer), then the device sharing is unnecessary and the X11 server can just "own" the device(s) all of the time. Moreover, if the kernel has been built without the built-in terminal emulator, there is nothing to negotiate with. Similarly, if an X11 server isn't actually using any I/O devices in the first place (as is the case with the Xvnc program) a mechanism for negotiating the ownership of I/O devices is unnecessary.

Further reading

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.