On Thu, Jul 04, 2024 at 03:18:04PM +0200, Lennart Poettering wrote: > On Do, 04.07.24 11:24, chenruyi (A) (chenruyi2@xxxxxxxxxx) wrote: > > > Hi, > > > > I have some processes in my initrd needed to be excluded from the killing spree > > during switch-root and needed to continue to run in the root file system. I read > > the ROOT_STORAGE_DAEMONS.md and the source code of killall.c, and I've learned > > that there are methods to exclude the processes from the killing spree, such as > > setting `@` to `argv[0][0]`. > > > > However, I'm not sure if this is without potential consequences. For example, could > > it be that even though my processes survive, some resources that the processes > > depends on are discarded after switch-root, such as file > > descriptors? > > No, these belong to your process, systemd couldn't really reach into > your processes to close them, even if it wanted to. > > But do note that any files you keep open or mapped at the moment of transition > will remain pinned in memory, and cannot be released by the > kernel. this means that even though during the tmpfs→host transition > we generally destory the initrd's tmpfs' contents, the stuff you keep > pinned will stick around. > > Generally, only special purpose software should be left around that > way, if it is carefully written to handle this. For example it is not > allowed to dlopen() anything (and hence no NSS either! No > gethostbyname() or getpwnam() or so), because you'd otherwise end up > with a weird mix of match of shared libs from the initrd and the host. If one does need to e.g. do DNS lookups in such a process, what is the best way to do it? -- Sincerely, Demi Marie Obenour (she/her/hers) Invisible Things Lab
Attachment:
signature.asc
Description: PGP signature