Merge "Don't wait after SIGKILL when freeze-killing" into udc-dev

This commit is contained in:
Treehugger Robot
2023-04-13 23:25:15 +00:00
committed by Android (Google) Code Review
3 changed files with 18 additions and 2 deletions

View File

@@ -1498,6 +1498,15 @@ public class Process {
*/
public static final native int killProcessGroup(int uid, int pid);
/**
* Send a signal to all processes in a group under the given PID, but do not wait for the
* processes to be fully cleaned up, or for the cgroup to be removed before returning.
* Callers should also ensure that killProcessGroup is called later to ensure the cgroup is
* fully removed, otherwise system resources may leak.
* @hide
*/
public static final native int sendSignalToProcessGroup(int uid, int pid, int signal);
/**
* Freeze the cgroup for the given UID.
* This cgroup may contain child cgroups which will also be frozen. If this cgroup or its

View File

@@ -1238,6 +1238,11 @@ jint android_os_Process_killProcessGroup(JNIEnv* env, jobject clazz, jint uid, j
return killProcessGroup(uid, pid, SIGKILL);
}
jint android_os_Process_sendSignalToProcessGroup(JNIEnv* env, jobject clazz, jint uid, jint pid,
jint signal) {
return sendSignalToProcessGroup(uid, pid, signal);
}
void android_os_Process_removeAllProcessGroups(JNIEnv* env, jobject clazz)
{
return removeAllProcessGroups();
@@ -1305,6 +1310,7 @@ static const JNINativeMethod methods[] = {
//{"setApplicationObject", "(Landroid/os/IBinder;)V",
//(void*)android_os_Process_setApplicationObject},
{"killProcessGroup", "(II)I", (void*)android_os_Process_killProcessGroup},
{"sendSignalToProcessGroup", "(III)I", (void*)android_os_Process_sendSignalToProcessGroup},
{"removeAllProcessGroups", "()V", (void*)android_os_Process_removeAllProcessGroups},
{"nativePidFdOpen", "(II)I", (void*)android_os_Process_nativePidFdOpen},
{"freezeCgroupUid", "(IZ)V", (void*)android_os_Process_freezeCgroupUID},

View File

@@ -47,6 +47,7 @@ import android.os.SystemClock;
import android.os.Trace;
import android.os.UserHandle;
import android.server.ServerProtoEnums;
import android.system.OsConstants;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.DebugUtils;
@@ -1186,8 +1187,8 @@ class ProcessRecord implements WindowProcessListener {
EventLog.writeEvent(EventLogTags.AM_KILL,
userId, mPid, processName, mState.getSetAdj(), reason);
Process.killProcessQuiet(mPid);
if (asyncKPG) ProcessList.killProcessGroup(uid, mPid);
else Process.killProcessGroup(uid, mPid);
if (!asyncKPG) Process.sendSignalToProcessGroup(uid, mPid, OsConstants.SIGKILL);
ProcessList.killProcessGroup(uid, mPid);
} else {
mPendingStart = false;
}