mirror of
https://github.com/NixOS/nix
synced 2025-06-24 18:01:16 +02:00
cgroups: reapp child processes before destroying cgroup
killing is enough to destroy a cgroup, we need to remove the wait state of zombie processes before we can destroy the cgroup.
This commit is contained in:
parent
469a6371ec
commit
7030d2e44f
1 changed files with 6 additions and 0 deletions
|
@ -8,6 +8,7 @@
|
|||
#include <cmath>
|
||||
#include <regex>
|
||||
#include <unordered_set>
|
||||
#include <sys/wait.h>
|
||||
#include <thread>
|
||||
|
||||
#include <dirent.h>
|
||||
|
@ -101,6 +102,11 @@ static CgroupStats destroyCgroup(const std::filesystem::path & cgroup, bool retu
|
|||
// FIXME: pid wraparound
|
||||
if (kill(pid, SIGKILL) == -1 && errno != ESRCH)
|
||||
throw SysError("killing member %d of cgroup '%s'", pid, cgroup);
|
||||
|
||||
while (waitpid(pid, nullptr, 0) == -1) {
|
||||
if (errno == ECHILD) break; // Process already reaped
|
||||
if (errno != EINTR) throw SysError("waiting for pid %d", pid);
|
||||
}
|
||||
}
|
||||
|
||||
auto sleep = std::chrono::milliseconds((int) std::pow(2.0, std::min(round, 10)));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue