Re: switch-root, init, SIGHUP

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sa, 18.01.25 05:40, James Muir (jamesmui) (jamesmui@xxxxxxxxx) wrote:

> I have a program, init-jm, that forks and executes
> /usr/lib/systemd/systemd in the parent (using execl() ) while the
> child collects some stats in a loop.

Uh, you can do this, but it's not trivial to get right: you need to
move yourself down the cgroup tree, because otherwise you'll collide
with cgroup's no-processes-in-inner-cgroup-nodes rule. Create two
cgroups in the root of the cgroup tree, then put your stuff in one,
and invoke systemd in the other. That's the only "correct" way to do
this, so that your stuff runs reasonably isolated from systemd.

> The child sets its argv[0][0] to ‘@’.
>
> init-jm is invoked using the “init” kernel parameter on a switch-root system (it’s Fedora 41).
>
> Can someone explain why systemd (PID 1) sends SIGHUP to the child?

Are you sure you are setting argv[0][0] properly? the killing spree we
do on switch root should exclude processes marked like that.

Note that we'll also possibly reinitialize the tty on switch root,
maybe your tool has the tty open and gets a SIGHUP because of that.

Lennart

--
Lennart Poettering, Berlin



[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux