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

Commit af76fe8a authored by Vairavan Srinivasan's avatar Vairavan Srinivasan Committed by Steve Kondik
Browse files

frameworks/base: watchdog to generate zygote's tombstone

Watchdog to use Process's getPpid to fetch zygote's pid and
generate its tombstone before killing system_server.

Change-Id: I4a5367dd927b880654c48a4e1675eed718a1f349
parent 50be217f
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -790,6 +790,9 @@ public class Process {
    /** @hide */
    public static final native int[] getPids(String path, int[] lastArray);

    /** @hide */
    public static final native int getPpid();
    
    /** @hide */
    public static final int PROC_TERM_MASK = 0xff;
    /** @hide */
+6 −0
Original line number Diff line number Diff line
@@ -129,6 +129,11 @@ jint android_os_Process_myTid(JNIEnv* env, jobject clazz)
    return androidGetTid();
}

jint android_os_Process_getPpid(JNIEnv* env, jobject clazz)
{
    return getppid();
}

jint android_os_Process_getUidForName(JNIEnv* env, jobject clazz, jstring name)
{
    if (name == NULL) {
@@ -904,6 +909,7 @@ static const JNINativeMethod methods[] = {
    {"getFreeMemory", "()J", (void*)android_os_Process_getFreeMemory},
    {"readProcLines", "(Ljava/lang/String;[Ljava/lang/String;[J)V", (void*)android_os_Process_readProcLines},
    {"getPids", "(Ljava/lang/String;[I)[I", (void*)android_os_Process_getPids},
    {"getPpid", "()I", (void*)android_os_Process_getPpid},
    {"readProcFile", "(Ljava/lang/String;[I[Ljava/lang/String;[J[F)Z", (void*)android_os_Process_readProcFile},
    {"parseProcLine", "([BII[I[Ljava/lang/String;[J[F)Z", (void*)android_os_Process_parseProcLine},
    {"getElapsedCpuTime", "()J", (void*)android_os_Process_getElapsedCpuTime},
+12 −0
Original line number Diff line number Diff line
@@ -460,6 +460,18 @@ public class Watchdog extends Thread {
                dropboxThread.join(2000);  // wait up to 2 seconds for it to return.
            } catch (InterruptedException ignored) {}

            if (!Debug.isDebuggerConnected()) {
            // Generate tombstone of zygote
            // zygote forks system_server
                 int zygotePid = Process.getPpid();
                 if (zygotePid > 0) {
                     Process.sendSignal(zygotePid, 6);
                     SystemClock.sleep(2000);
                     Process.sendSignal(zygotePid, 6);
                     SystemClock.sleep(2000);
                 }
            }

            // Only kill the process if the debugger is not attached.
            if (!Debug.isDebuggerConnected()) {
                Slog.w(TAG, "*** WATCHDOG KILLING SYSTEM PROCESS: " + name);