A rough outline of how X works

April 23, 2011 at 12:08 pm Leave a comment

In the past, I’d always thought of invoking X as somewhat arcane. It turns out I’m that wrong: The basic X set up is straightforward – the complexity is generated by all the glue.

X windows basically consists of a server process, ‘X’. Other programs (clients) communicate with this process through a socket interface using a binary protocol (normally a unix domain socket, but this can also be a tcp socket).

Each X server uses a free virtual terminal for display. By default, the virtual terminal with the lowest number is used – but one can also specify which virtual terminal to use.

To support multiple X servers on a single machine, each X server is given a name like ‘:0’ or ‘:1’: This is termed a display. Processes that want to use a particular X server use this name to communicate with the X server.

(Under the hood, an appropriate unix domain socket file is created in tmp named after the display, or the display number is converted into a tcp port around 6000).

Together this means that getting a primitive X is terribly simple (though insecure if you don’t have a firewall and can’t trust the other users of your machine (including the non-human ones):

X :1
#X :1 vt10 would start X on tty10
DISPLAY=:1 xterm&

When you start X normally with xinit (or via [gxk]dm), it uses additional authentication and switches off tcp.


Entry filed under: Uncategorized. Tags: .

Adventures with linux (virtual) terminals DESTDIR – Build to a different location

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Trackback this post  |  Subscribe to the comments via RSS Feed

April 2011
« Mar   May »

%d bloggers like this: