Re: s6 xinit replacement?

From: Laurent Bercot <>
Date: Sun, 15 May 2022 01:52:11 +0000

>Is the purpose of executing setsid() in s6-supervise to allow for the
>services to continue beyond the termination of the supervision tree?

  It's actually the opposite: it's to protect the supervision tree
against misbehaved services. :) setsid() makes sure the service is
isolated, and a killpg() or equivalent won't affect anything outside
of it. Of course, it also protects *other* services running under the
same supervision tree.

>If that's the case, could there possibly be a flag to disable that,
>with the understanding that something like nohup or even s6-setsid would
>be necessary to replicate that behavior? That would enable a non-root
>Xorg to be managed by s6.

  The direction s6 has taken is really the opposite: there was such a
flag in earlier versions, but it was causing a lot of special cases
and problems I definitely did not want to deal with.
  The real issue is that a supervision tree should not be run with a
controlling terminal. It's not meant to be run from a logged-in user
process, but as a background infrastructure that's always there. The
whole point of s6 is to make your services *more reliable*; and there
are few things less reliable than a whole tree of processes that can
die on an accidental ^C.

  Because users insisted a lot, there are still accommodations for
killing a whole supervision tree with ^C when s6-svscan has been
in a terminal. It is a nice feature to have (and although it was by
that services persisted beyond the ^C, it was unintuitive to most users,
so from a pure UI standpoint, killing the entire tree in one go was
  However, I'm not going back on the "each service runs in its own
thing, because if there's a case for allowing the user who controls
s6-svscan to kill the whole tree at once, there is just no case for
allowing a service running under the tree to impact other services and
the tree itself.

  Despite this, you're right that the pattern of xinit is similar to what
s6 does, and it *is* possible to run Xorg under s6; several users are
doing so, and I hope they will post their setup. (You may have more
luck by asking in the IRC channel, but it would be nice for the setup
to be documented on the mailing-list.) It does not involve running
s6-svscan from your own VT; it involves having a supervision tree
already running (as your user), and starting the Xorg service, e.g.
with a s6-svc -u command, on a given VT, possibly passed to the run
script via a file that your xinit emulation script would fill in
with the output of `tty`.

  If you insist on doing hacky things, you could even probably get away
with something that looks like:

xinit emulation:
tty | sed s:/dev/tty:: > /home/me/.screen-number
s6-supervise /home/me/Xorg &
# small race here that disappears when s6-supervise has already run once
s6-svwait -U /home/me/Xorg
s6-svc -dx /home/me/Xorg


#!/bin/execlineb -P
backtick -E screen { cat /home/me/.screen-number }
export DISPLAY :$screen
X -displayfd 3 :$screen vt$screen

-displayfd is used as a notification mechanism, unblocking s6-svwait
when the X server is ready.

  Hope this helps (and I hope users who actually have done something
similar will share their experience),

Received on Sun May 15 2022 - 03:52:11 CEST

This archive was generated by hypermail 2.4.0 : Sun May 15 2022 - 03:52:42 CEST