John Tsiombikas <
nuc...@member.fsf.org> wrote:
> On 2022-05-30, Kaz Kylheku <
480-99...@kylheku.com> wrote:
>>
>> Let's make it clear; systemd (or something like it) is necessary and
>> that is why distros bundle it and use it.
>
> [citation needed]
>
>> (The answer isn't necessarily going back to some scattered shell
>> scripts to duct-tape everything together; that's the strawman
>> characterization of the systemd nay-sayers as a group, even though
>> a few do advocate exactly that.)
>
> I'll have my scattered shell scripts thank you very much.
Shell scripts cannot fix bad process management in the daemons themselves.
So either process management in the daemons needs to be comprehensively
fixed and maintained (see OpenBSD), or it needs to be removed, in which case
you still need infrastructure such as daemontools or systemd to juggle
processes.
Process management can't always be removed, though, as some daemons need to
manage subprocesses for various legitimate reasons. And that's where we end
up with irreducible complexity. Process management isn't *that* difficult,
but manifestly people on average suck at it. Herculean efforts at mitigating
and papering over those issues is where most of the complexity of systemd's
init system arises.
For my tastes, I prefer fixing the actual software. But in the context of
the broader Linux ecosystem, that approach alone isn't reasonable. (It's
more reasonable on OpenBSD, where the most commonly used daemons are
maintained as part of the system, and the general user and developer base is
a self-selective bunch.) I'm not a systemd fan, but in some ways systemd
seems almost inevitable.
If I had more time and motivation I might try to implement a different
compromise: introducing more sophisticated process management primitives
directly into the shell. Job management is, afterall, a core competency of
the shell, and despite it's innumerable problems it still excels relative to
other languages, at least for the simple stuff. I suspect it might make
sense to implement a POSIX-compliant shell from scratch, probably in a
higher-level language like Lua or Go, making it easier and faster to
implement and integrate more complex builtins (commands, operators,
semantics) for process management--e.g. process descriptors, asynchronous
in-process events beyond simple signals, etc. But, realistically, extending
bash or dash might be the better approach to maximize chances of widespread
adoption.
Success might still be contingent on fixing and complementing existing
kernel facilities, especially if you want to achieve correctness without
centralizing everything under, e.g., PID 1 init. (For example, process
descriptor semantics and interfaces might not be improved.) Even systemd
still falls short of semantic correctness as it's still technically
susceptible to some of the same races as traditional PID files. When I've
brought this up on LWN.net, people have pointed out that correctness might
be achievable by leveraging more recent Linux kernel facilities, but systemd
doesn't yet use them and might not ever be able to use them as-is.
Ultimately, I doubt a more holistic approach can be avoided. Confining a
solution to ad hoc shell scripts preserves the same fundamental error as
systemd preserved, which also tries to solve everything without fixing code
elsewhere. (I know systemd developers do sometimes propose and submit kernel
patches, but approaches and outcomes still seem lacking.)