libprocessgroup: Add sendSignalToProcessGroup
Add a function which sends signals to all members of a process group, but does not wait for the processes to exit, or for the associated cgroup to be removed. Bug: 274646058 Ignore-AOSP-First: Dependency of ActivityManager change which developed on interal git_master Test: Force-stop of chrome with 15 tabs completes ~500ms faster Test: Full Play store update causes no ANR (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:d87b6018d25cbbd33b345dc58c634718bf5d0def) Merged-In: I37dbdecb3394101abbee8495e71f6912b3c031f5 Change-Id: I37dbdecb3394101abbee8495e71f6912b3c031f5
This commit is contained in:
parent
c7e85ebc00
commit
d3dc653d22
2 changed files with 14 additions and 0 deletions
|
@ -76,6 +76,11 @@ int killProcessGroup(uid_t uid, int initialPid, int signal, int* max_processes =
|
|||
// that it only returns 0 in the case that the cgroup exists and it contains no processes.
|
||||
int killProcessGroupOnce(uid_t uid, int initialPid, int signal, int* max_processes = nullptr);
|
||||
|
||||
// Sends the provided signal to all members of a process group, but does not wait for processes to
|
||||
// exit, or for the cgroup to be removed. Callers should also ensure that killProcessGroup is called
|
||||
// later to ensure the cgroup is fully removed, otherwise system resources may leak.
|
||||
int sendSignalToProcessGroup(uid_t uid, int initialPid, int signal);
|
||||
|
||||
int createProcessGroup(uid_t uid, int initialPid, bool memControl = false);
|
||||
|
||||
// Set various properties of a process group. For these functions to work, the process group must
|
||||
|
|
|
@ -542,6 +542,15 @@ int killProcessGroupOnce(uid_t uid, int initialPid, int signal, int* max_process
|
|||
return KillProcessGroup(uid, initialPid, signal, 0 /*retries*/, max_processes);
|
||||
}
|
||||
|
||||
int sendSignalToProcessGroup(uid_t uid, int initialPid, int signal) {
|
||||
std::string hierarchy_root_path;
|
||||
if (CgroupsAvailable()) {
|
||||
CgroupGetControllerPath(CGROUPV2_CONTROLLER_NAME, &hierarchy_root_path);
|
||||
}
|
||||
const char* cgroup = hierarchy_root_path.c_str();
|
||||
return DoKillProcessGroupOnce(cgroup, uid, initialPid, signal);
|
||||
}
|
||||
|
||||
static int createProcessGroupInternal(uid_t uid, int initialPid, std::string cgroup,
|
||||
bool activate_controllers) {
|
||||
auto uid_path = ConvertUidToPath(cgroup.c_str(), uid);
|
||||
|
|
Loading…
Reference in a new issue