As of November 2014, the latest versions of startxwin
use xinit
to start the Cygwin/X server, which is actually called XWin.exe
. The process goes something like this:
- You call
startxwin
startxwin
creates a new .Xauthority
file and one called .serverauth.1234
(where 1234
changes each time you start X)
startxwin
sets up some client and server parameters
startxwin
calls xinit
with the client and server parameters, including some optional shell scripts and a reference to the auth file.
xinit
starts the X server, running some of the rc scripts
xinit
starts the client (usually xterm
) or client rc script. We want to avoid this
- When you close the client or the client rc script finishes,
xinit
shuts down the X server. If we avoid step 6, we also need to avoid this
It is possible to run XWin.exe
directly from within a Bash login shell, without the surrounding tasks that startxwin
and xinit
perform. The main advantage of this is that it behaves like we want: the X server starts and remains running. Unfortunately, since there is no .Xauthority
file passed during startup, your X server would permit any local process to connect to it, which is insecure.
Fortunately it's xinit
that does most of the stuff we don't want. There's a quick hack that bypasses xinit
but keeps the remaining elements of startxwin
that are related to the server itself.
TL;DR: In startxwin
, there's a line near the bottom that reads:
eval xinit \"$client\" $clientargs -- \"$server\" $display $serverargs
Change that line to:
eval \"$server\" $display $serverargs
From now on, the startxwin
script will call XWin.exe
directly, rather than calling xinit
. Obviously this will disable any client rc scripts, but we didn't want those in the first place. It also means that X will continue running without needing a client process to keep it alive (i.e. keep xinit
from killing it).