Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 304c0f1c authored by Jing Ji's avatar Jing Ji
Browse files

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
parent 2a2760fe
Loading
Loading
Loading
Loading
+9 −12
Original line number Diff line number Diff line
@@ -406,11 +406,7 @@ 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;
        }

        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);
@@ -421,6 +417,7 @@ static int DoKillProcessGroupOnce(const char* cgroup, uid_t uid, int initialPid,
                }
            }
        }
    }

    int processes = 0;
    // Kill all process groups.