From: Danny Milosavljevic <dannym@scratchpost.org>
To: Carlo Zancanaro <carlo@zancanaro.id.au>
Cc: guix-devel@gnu.org
Subject: Re: Improving Shepherd
Date: Mon, 5 Feb 2018 17:00:11 +0100 [thread overview]
Message-ID: <20180205170011.73780f13@scratchpost.org> (raw)
In-Reply-To: <877errn23f.fsf@zancanaro.id.au>
Hi Carlo,
On Mon, 05 Feb 2018 21:49:08 +1100
Carlo Zancanaro <carlo@zancanaro.id.au> wrote:
> User services - Alex has already sent a patch to the list to allow
> generating user services from the Guix side. The idea is to
> generate a Shepherd config file, allowing a user to invoke
> shepherd manually to start their services.
>A further extension to
> this would be to have something like systemd's "user sessions",
> where the pid 1 Shepherd automatically starts a user's services
> when they log in.
I assume that means "starts a user's shepherd when they log in".
elogind already emits a signal on dbus which tells you when a user logged in
return sd_bus_emit_signal(
u->manager->bus,
"/org/freedesktop/login1",
"org.freedesktop.login1.Manager",
new_user ? "UserNew" : "UserRemoved",
"uo", (uint32_t) u->uid, p);
Also, a directory /run/user/<id> appears - which alternatively can be
monitored by inotify or something.
So the system shepherd could have a shepherd service which does
while (1) {
wait until /run/user/<id> appears
vfork
if child: setuid, exec user shepherd, _exit
if parent: wait until child dies
}
We better be sure that no one else can create directories in /run/user .
In non-pseudocode, both "wait until /run/user/<id> appears" and
"wait until child dies" would have to be in the same call,
maybe epoll or something.
Maybe call the service shepherd-nursery-service or something, like a star
nursery :)
> Child process control - this is my personal frustration, where
> Shepherd loses track of processes that fork away (e.g. "emacs
> --daemon"). I barely know anything about Linux process management,
> but from my reading this can be solved through Linux namespaces
> (if user namespaces are available). Could someone who knows more
> about this let me know if that's a productive direction for me to
> investigate? Or tell me a better way to go about it?
User namespaces just present a different set of names to your process
(via VFS) so it looks like a chroot basically.
It does nothing for processes except fake their ids and limit your
overview of them.
You probably want process groups (see setsid(2)) or maybe containers.
next prev parent reply other threads:[~2018-02-05 16:00 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-29 21:14 Improving Shepherd Carlo Zancanaro
2018-01-29 22:27 ` Jelle Licht
2018-02-05 10:49 ` Carlo Zancanaro
2018-02-05 13:08 ` Ludovic Courtès
2018-02-05 15:56 ` Carlo Zancanaro
2018-02-09 13:26 ` Ludovic Courtès
2018-02-09 19:50 ` Carlo Zancanaro
2018-02-09 21:32 ` Christopher Lemmer Webber
2018-02-14 13:10 ` Ludovic Courtès
2018-02-15 13:55 ` Andy Wingo
2018-02-10 13:34 ` Jelle Licht
2018-02-14 13:25 ` Ludovic Courtès
2018-02-15 17:05 ` Jelle Licht
2018-02-15 19:04 ` Mark H Weaver
2018-02-05 16:00 ` Danny Milosavljevic [this message]
2018-02-05 16:41 ` Carlo Zancanaro
2018-02-09 13:22 ` Ludovic Courtès
2018-02-09 20:51 ` David Pirotte
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=20180205170011.73780f13@scratchpost.org \
--to=dannym@scratchpost.org \
--cc=carlo@zancanaro.id.au \
--cc=guix-devel@gnu.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.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.