supervision - discussion about system services, daemon supervision, init, runlevel management, and tools such as s6 and runit
 help / color / mirror / Atom feed
From: "Laurent Bercot" <ska-supervision@skarnet.org>
To: supervision@list.skarnet.org
Subject: Re: ipc in process #1
Date: Fri, 10 May 2019 17:57:09 +0000	[thread overview]
Message-ID: <em1f23354c-db66-49e8-a561-d73fce7bbbfb@elzian> (raw)
In-Reply-To: <20190509071019.GE4017@panda>


>IMO process #1 should be solely signal driven.
>i guess there is no need for further ipc by other means,
>escpecially for those that require rw fs access to work
>(eg fifos, unix sockets).

The devil is in the details here. Theoretically, yes, you're right.
In practice, only using signals to control pid 1 is rather limiting,
and the choice to do so or not to do so is essentially decided by
other factors such as the existing interfaces you want to follow.

For instance, if you want to implement the stage 3 procedure in
pid 1, and you want to follow the LSB interface for the "shutdown"
binary - all of which is the case for sysvinit - then signals are
not enough: you need to be able to convey more information to pid 1
than a few signals can.

But yes, limiting what pid 1 does is reducing its attack surface,
which is a good idea in general, and it is totally possible to
design a correct pid 1 that is only controlled by signals.


>apart from that process #1 has IMO only the additional duty of
>leaving stage 2 and entering staqe 3 when requested.

And reaping zombies, and supervising at least one process. :)


>for those who still need more than what is provided by signals
>i would recommend using abstract unix domain sockets (Linux only)
>or SysV message queues (the latter works even on OpenBSD) since
>those ipc mechanisms can work properly without rw fs access.

Have you tried working with SysV message queues before recommending
them? Because my recommendation would be the exact opposite. Don't
ever use SysV message queues if you can avoid it. The API is very
clumsy, and does not mix with event loops, so it constrains your
programming model immensely - you're practically forced to use threads.
And that's a can of worms you certainly don't want to open in pid 1.

Abstract sockets are cool - the only issue is that they're not
portable, which would limit your init system to Linux only. If you're
going for a minimal init, it's a shame not to make it portable.

Really, the argument for an ipc mechanism that does not require a
rw fs is a weak one. Every modern Unix can mount a RAM filesystem
nowadays, and it is basically essential to do so if you want early
logs. Having no logs at all until you can mount a rw fs is a big
no-no, and being unable to log what your init system does *at all*,
unless you're willing to store everything in RAM until a rw fs
comes up, is worse. An early tmpfs technically stores things in RAM
too, but is much, *much* cleaner, and doesn't need ad-hoc code or
weird convolutions to make it work.

Just use an early tmpfs and use whatever IPC you want that uses a
rendez-vous point in that tmpfs to communicate with process 1.
But just say no to message queues.

--
Laurent



  reply	other threads:[~2019-05-10 17:57 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-09  7:10 Jeff
2019-05-10 17:57 ` Laurent Bercot [this message]
2019-05-11 11:26   ` SysV shutdown util Jeff
2019-05-11 12:56     ` Laurent Bercot
2019-05-11 12:38   ` emergency IPC with SysV message queues Jeff
2019-05-11 13:34     ` Laurent Bercot
2019-05-16 15:15       ` Jeff
2019-05-16 21:25         ` Laurent Bercot
2019-05-16 21:54           ` Oliver Schad
2019-05-19 17:54           ` Jeff
     [not found]             ` <CALZWFRJws+eDthy8MCFj4PiVdRdRpM+afda6QAbEtYA4NT8ESQ@mail.gmail.com>
2019-05-19 19:59               ` Fwd: " Cameron Nemo
2019-05-19 20:26             ` Jeff
2019-05-19 18:38           ` Bob

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=em1f23354c-db66-49e8-a561-d73fce7bbbfb@elzian \
    --to=ska-supervision@skarnet.org \
    --cc=supervision@list.skarnet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).