Booting, s6-rc services and controlling terminal

From: Guillermo <>
Date: Sat, 2 Apr 2016 12:56:02 -0300


Excuse me if this is a basic POSIX question.

Consider a machine with an s6-linux-init-maker-style setup, that also
uses s6-rc in the stage2 and stage2_finish scripts. Longruns managed
by s6-rc without a 'producer-for' file in their definition directory
have their stdout and stderr redirected to the catch-all logger, and
so do oneshots via the s6rc-oneshot-runner service. So if one wants to
have a service output to the console instead (e.g. an early one in the
boot process), its definition would have to do explicit redirections
to /dev/console. But should the service also be turned into a session
leader and set a controlling terminal, or only in special cases?

I thought that this was needed only in special cases, like in
processes that end up spawning a shell, but I see other init systems
sometimes do it automatically. For example, with nosh, a service
configured to output to a terminal AND defined using a systemd unit
file, when converted to a bundle directory (nosh's version of a
service definition directory) with the converter tool, has a 'run'
script that calls open-controlling-tty (nosh's chainloading utility to
open a device as a controlling terminal). And sysvinit's code has
setsid() and TIOCSCTTY ioctl() calls for child processes, depending on
the 'runlevel' and 'action' fields of the corresponding line in

What those two cases have in common is that the mechanism involved
also unconditionally redirects stdin to a terminal device; in the nosh
case, I'm not sure if because of a limitation of the unit
file-to-bundle directory converter. But I don't know why the
"controlling terminal maneuver" is done there, so I now wonder if
s6-rc service definitions would also require it in more cases than I
thought, instead of simple FD redirections.

Received on Sat Apr 02 2016 - 15:56:02 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:38:49 UTC