On Tue, 24 Nov 2026 18:46:29 +0000
Sergei Zimmerman
and at that point it looked like you could just let pasta do its job and daemonise itself
Forgive me if I’m slightly incorrect on the details, but here’s the simplification that can be done in the lix build launcher: https://gerrit.lix.systems/c/lix/+/6897
Sure, I understand that's a significant simplification. It's the same as what we discussed back in June, though. I'm just suggesting that you can get the same simplification by letting pasta do its course, that is, drop the '--foreground' option, and it will behave like all regular UNIX daemons do: it forks to background once it's ready, and not a moment before: https://archives.passt.top/passt-dev/cbe5ab63-3266-4234-8745-5a6583039809@re... https://archives.passt.top/passt-dev/20260527213924.2586bca5@elisabeth/ No reason for a side channel just because slirp4netns had it. And yes, Podman used to do that too, but eventually I convinced them to fix that. :) When you're done with the namespace, you don't need to track pasta at all: just remove the namespace handle, and pasta goes away. I saw the "We don't let it daemonize itself for process managements reasons" comment, it was the same in June, but when Lisanna checked it appeared to be a left-over. Or at least we couldn't figure out what those particular "process managements reason" were. If you want something explicit for corner cases, though:
There’s several arguments I see for the ready pipe:
* Asynchronous waiting for the child exit is painful without pidfd. This seems relevant for lix.
...we discussed providing a pidfd for some particular use cases in Podman as well. All pasta can do (on top of automatic exit) is to write a PID file, but it's racy, strictly speaking. If that solves a problem for Lix as well, let's implement that instead. This --ready-fd option scares me enough (both in terms of letting something "wrong" slip in now, as well as hours of fun with AppArmor / SELinux once others start using it) that I'd rather be inclined in investing a bit of time in the pidfd thing myself. Of course, I don't want to force that option if it's really not suitable for your purposes... but perhaps it is?
* The setup completion is waited upon in another child process of lix while the parent that spawned pasta goes off on its merry way, so I’m not even sure you *could* wait for the daemonization to complete in this process setup?
Just fork(), exec(), and wait for the child to exit before proceeding, instead of keeping a separate child process around implementing more specific synchronisation. Even with a file descriptor indicating readiness, you would need to wait anyway, right?
I’d need to brush up on pidfd polling and whether it can work around wait4 limiting you to child processes.
I think you could still use wait4() or similar.
As for the other commit, fd inheritance seems like a useful simplification. Closing leaked FDs is the parent’s responsibility that cppnix and lix* already handle so whatever is inherited is done intentionally.
Until you forget to do that, and then it's our responsibility. :) And even if it's not, it risks getting catastrophically bad. I mean, if people want to run Bubblewrap *inside* pasta, ouch... but fine, there I understand the need to pass file descriptors down to the spawned command. But if you don't need to let pasta spawn any command, if the only purpose is to pass a network namespace without using a filesystem path, then give pasta your PID? Wouldn't that work? If, for some reason I'm missing, you really need to pass the namespace as file descriptor, I'd rather implement that as a special option that only applies to network namespaces and nothing else, and keep closing any (otherwise) leaked file descriptor. I really would like to avoid the risk of having anything unnecessary and potentially dangerous in pasta's descriptor table, *if possible*. -- Stefano