Merge "Kill its process group even if the given process is already dead"

This commit is contained in:
Suren Baghdasaryan 2023-02-28 18:25:57 +00:00 committed by Gerrit Code Review
commit 763593e395

View file

@ -406,18 +406,15 @@ static int DoKillProcessGroupOnce(const char* cgroup, uid_t uid, int initialPid,
pids.emplace(pid);
}
}
if (file_is_empty) {
// This happens when process is already dead
return 0;
}
// Erase all pids that will be killed when we kill the process groups.
for (auto it = pids.begin(); it != pids.end();) {
pid_t pgid = getpgid(*it);
if (pgids.count(pgid) == 1) {
it = pids.erase(it);
} else {
++it;
if (!file_is_empty) {
// Erase all pids that will be killed when we kill the process groups.
for (auto it = pids.begin(); it != pids.end();) {
pid_t pgid = getpgid(*it);
if (pgids.count(pgid) == 1) {
it = pids.erase(it);
} else {
++it;
}
}
}
}