From 05fed0687d60088a7776dec565c3679de2724f7b Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Wed, 28 Jan 2026 18:49:02 +0100 Subject: [PATCH] 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 --- lix/libstore/platform/linux.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lix/libstore/platform/linux.cc b/lix/libstore/platform/linux.cc index 8dd3a1855..51f4394d3 100644 --- a/lix/libstore/platform/linux.cc +++ b/lix/libstore/platform/linux.cc @@ -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.