libstore: add processes to cgroups earlier

this was racy previously; a builder may have spawned processes before we
added it to a cgroup. these processes would not be registered correctly.

Change-Id: If60a64a798ee806d5701590a83d1015f55d7b867
This commit is contained in:
eldritch horrors
2026-01-28 18:49:02 +01:00
parent b23bbd5b19
commit 05fed0687d
+5 -5
View File
@@ -1479,6 +1479,11 @@ Pid LinuxLocalDerivationGoal::startChild(
throw SysError("failed to redirect build output to log file");
}
/* Migrate the child inside the available control group. */
if (context.cgroup) {
context.cgroup->adoptProcess(getpid());
}
/* Drop additional groups here because we can't do it
after we're in the new user namespace. */
if (setgroups(0, 0) == -1) {
@@ -1510,11 +1515,6 @@ Pid LinuxLocalDerivationGoal::startChild(
);
});
/* Migrate the child inside the available control group. */
if (context.cgroup) {
context.cgroup->adoptProcess(pid.get());
}
if (runPasta()) {
// Bring up pasta, for handling FOD networking. We don't let it daemonize
// itself for process managements reasons and kill it manually when done.