Re: [systemd-devel] switch-root, init, SIGHUP

2025-01-21 Thread James Muir (jamesmui)
> > I think the SIGHUP must come from the new PID 1. > > I don't know if this will help you, however here is a program that I > wrote last year that starts a service in the initramfs, it survives > the systemd killing spree during the transition to the root > filesystem, a new copy of the program i

Re: [systemd-devel] switch-root, init, SIGHUP

2025-01-20 Thread Brian Masney
Hey James, On Mon, Jan 20, 2025 at 1:21 PM James Muir (jamesmui) wrote: > I think the SIGHUP must come from the new PID 1. I don't know if this will help you, however here is a program that I wrote last year that starts a service in the initramfs, it survives the systemd killing spree during the

Re: [systemd-devel] switch-root, init, SIGHUP

2025-01-20 Thread James Muir (jamesmui)
> > It is not clear to me if the '@' is necessary because the process is > > invoked using the "init" kernel parameter. > > That detail doesn't matter. It's irrelevant how the process gets > started. In particular as I understand you you fork()ed once, > i.e. init= starts PID 1, but this is not PID

Re: [systemd-devel] switch-root, init, SIGHUP

2025-01-20 Thread Lennart Poettering
On Mo, 20.01.25 18:21, James Muir (jamesmui) (james...@cisco.com) wrote: > > Are you sure you are setting argv[0][0] properly? the killing spree we > > do on switch root should exclude processes marked like that. > > When I check /proc//cmdline, I see the '@' character. > > It is not clear to me i

Re: [systemd-devel] switch-root, init, SIGHUP

2025-01-20 Thread James Muir (jamesmui)
> > 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'l

Re: [systemd-devel] switch-root, init, SIGHUP

2025-01-20 Thread Lennart Poettering
On Sa, 18.01.25 05:40, James Muir (jamesmui) (james...@cisco.com) 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

Re: [systemd-devel] switch-root, init, SIGHUP

2025-01-20 Thread James Muir (jamesmui)
> I suspect that your process has a controlling tty based on this comment > in the killall() function at src/shared/killall.c: > >if (send_sighup) { >/* Optionally, also send a SIGHUP signal, but only if the process > has a controlling > * tty. This is useful to allow h

Re: [systemd-devel] switch-root, init, SIGHUP

2025-01-20 Thread Brian Masney
Hi James, On Sat, Jan 18, 2025 at 05:40:17AM +, James Muir (jamesmui) 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. > > The child sets its argv[0][0] to ‘@’. > > init-jm is

[systemd-devel] switch-root, init, SIGHUP

2025-01-17 Thread James Muir (jamesmui)
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. 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 som