Merge "Kill its process group even if the given process is already dead" am: 763593e395

Original change: https://android-review.googlesource.com/c/platform/system/core/+/2459289

Change-Id: Icb4b2f94a5ade70ad3ead99a8898cca301dc53b3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Suren Baghdasaryan 2023-02-28 19:35:59 +00:00 committed by Automerger Merge Worker
commit 2038ed868b

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;
}
}
}
}