Find a free X11 display number
问题 I have some unit tests that need an X11 display so I plan to start Xvfb before running them, but to start Xvfb I will need a free display number to connect it to. My best guess is to see what's free in /tmp/.X11-unix but I'm not sure how to handle the race if many tests try to start simultaneously. sshd must do this, does anyone know how? 回答1: With full credit to this answer to the related question How high do X11 display numbers go?: Recent X servers as of version 1.13 ( Xvfb , too) support