Kill its process group even if the given process is already dead
So the child processes in the process group won't be orphaned when we decide to kill the process group of a given process but find it's already dead. Bug: 266633286 Test: atest MicrodroidDemoApp Change-Id: Ib6f45b992566f0ab5cf152463c95294a306dd736
This commit is contained in:
parent
2a2760fe0a
commit
304c0f1c14
1 changed files with 9 additions and 12 deletions
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue