:: [DNG] What is an init system?
Inizio della pagina
Delete this message
Reply to this message
Autore: Steve Litt
Data:  
To: dng
Oggetto: [DNG] What is an init system?
Hi all,

Just so we're on the same page, an init system is a PID1 plus code
(could be a shellscript) to do all config, mounting, and system setup,
as well as starting up all the daemons. To a greater or lesser or
possibly zero extent, this code, which might be a shellscript or might
not, also controls the daemons on an ongoing basis running of daemons
and in many cases gives the admin an easy way to start, stop and
restart daemons.

Under the preceding definition, you could compile Rich Felker's 16 line
PID1 program, which reaps zombies and forks off a shellscript called rc
to do the rest of the boot.

In real life PID1 needs to respond to a few more signals. Suckless
Init, as displayed at
https://git.suckless.org/sinit/file/sinit.c.html, does this. On ALRM and
CHLD it reaps a zombie. On USR1 it powers down, and on INT it reboots.
What it does to power up or power down is defined in the .h file, which
can be as simple as running a shellscript.

Runit is built pretty much this same way, but separates mounting and
configuration (stage 1) from daemon supervision (stage 2), and moves
some other work, especially backgrounding the daemons, to itself, so
neither the run script authors nor the daemon authors need to worry
about backgrounding anything.

S6 is pretty much the same as runit except that s6 includes in PID1
code to restart the rest of the boot. The last few years other separate
programs have been added to s6 to facilitate specific ordering of
daemon startup at runtime, which is absent from s6. S6 also now has
code to receive from the daemon the news that the daemon is now running
and ready. S6's readiness notification system is simply an open fifo or
something like that and is MUCH simpler than systemd's crazy readiness
notification system. S6 has been built up in the past few years to
include all *reasonable and necessary* features of systemd, done in a
much simpler and more modular way.

I'd love to explain how OpenRC, sysvinit and systemd work, but I don't
have a clue :-).

SteveT

Steve Litt

Autumn 2023 featured book: Rapid Learning for the 21st Century
http://www.troubleshooters.com/rl21