The simplest way to start an X session has to be the startx(1) script.

However, startx(1) is only wrapping another tool to provide sane
defaults. The original command here is xinit(1), so the real question is,

# how does `xinit` works?

Here is what happens:

1. xinit starts
2. xinit executes and fork X(7) 
3. xinit executes ~/.xinitrc or the command given as a parameter
4. xinit kills X
5. xinit stops

As long as X is running, your graphical session will be up. So the ONLY way to
keep it running longer than a few seconds is to make the ~/.xinitrc script
blocking. because, if xinit is stuck at step 3, it will not reach step 4, so
your session will run for a longer time. So just add a "blocking" command at the
end of your xinitrc, to have it running ad eternam:

    xsetroot -solid gray
    cwm &

By using this, your X session will stay up and running until you kill the
terminal. Any blocking program would do, just like this `xwait` script:

	while :; do sleep 10000; done

For those who would like a nice pstree(1) output, you can use exec(1) to have
the /bin/sh process replaced by the command passed, turning this:


into this :


Know you can find a smart way to waste all these resources you saved ! 🙃