Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How high do X11 display numbers go?

Tags:

x11

The displayno is part of the X11 display name.

I have seen several definitions that explain it is a number from 0 upwards, but I haven't seen any documents that explain if there is a maximum display number.

What is the highest display number? Where is it defined?


The background for this question is that I am trying to understand the Display number allocation algorithm of PyVirtualDisplay. I haven't understood the role of the /tmp/.X*lock files yet, but it looks like the allocation routine will choose always increasing display numbers, suggesting at some stage of repeatedly being invoked it might hit the limit and fall over, especially if it is small.

like image 666
Oddthinking Avatar asked Aug 28 '12 06:08

Oddthinking


2 Answers

2147483647 which is 2**31 - 1

Xephyr :2147483647
Xephyr :2147483648 # Bad display name

found with brute force:

for ((i=4153577566; i > 0; i -= 10000000 )); do echo $i; Xephyr :$i 2>/dev/null && break; done
for ((i=2153577566; i > 0; i -= 100000 )); do echo $i; Xephyr :$i 2>/dev/null && break; done
for ((i=2147577566; i > 0; i -= 1000 )); do echo $i; Xephyr :$i 2>/dev/null && break; done
...
like image 136
Mila Nautikus Avatar answered Oct 15 '22 21:10

Mila Nautikus


Short answer: it's not well defined.

Longer answer: it depends on the stream protocol you happen to be using. In TCP it happens to be simply added to the base port number of 6000, which means the server will fail to launch somewhere around display number 59535. Over unix domain sockets it's just an integer appended to the socket name under /tmp/.X11-unix (so if you're launching the server with -nolisten tcp you can have a few billion or so). In DECnet... well, I don't know, but if you ever find yourself in a situation to care, I'm very sorry.

Possibly better answer for posterity: if you're using a sufficiently new X server, you can use the -displayfd <n> argument to tell the server to simply pick an available display number, and write it back to you on that file descriptor. Think that's new in xserver 1.13, which should be out late 2012.

like image 40
ajax Avatar answered Oct 15 '22 23:10

ajax