Loading core/jni/com_android_internal_os_Zygote.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include <sys/prctl.h> #include <sys/resource.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <sys/utsname.h> #include <sys/wait.h> Loading Loading @@ -151,6 +152,24 @@ static void SetSigChldHandler() { } } // Resets nice priority for zygote process. Zygote priority can be set // to high value during boot phase to speed it up. We want to ensure // zygote is running at normal priority before childs are forked from it. // // This ends up being called repeatedly before each fork(), but there's // no real harm in that. static void ResetNicePriority(JNIEnv* env) { errno = 0; int prio = getpriority(PRIO_PROCESS, 0); if (prio == -1 && errno != 0) { ALOGW("getpriority failed: %s\n", strerror(errno)); } if (prio != 0 && setpriority(PRIO_PROCESS, 0, 0) != 0) { ALOGE("setpriority(%d, 0, 0) failed: %s", PRIO_PROCESS, strerror(errno)); RuntimeAbort(env, __LINE__, "setpriority failed"); } } // Sets the SIGCHLD handler back to default behavior in zygote children. static void UnsetSigChldHandler() { struct sigaction sa; Loading Loading @@ -448,6 +467,8 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra SetForkLoad(true); #endif ResetNicePriority(env); pid_t pid = fork(); if (pid == 0) { Loading Loading @@ -692,4 +713,3 @@ int register_com_android_internal_os_Zygote(JNIEnv* env) { return RegisterMethodsOrDie(env, "com/android/internal/os/Zygote", gMethods, NELEM(gMethods)); } } // namespace android Loading
core/jni/com_android_internal_os_Zygote.cpp +21 −1 Original line number Diff line number Diff line Loading @@ -36,6 +36,7 @@ #include <sys/prctl.h> #include <sys/resource.h> #include <sys/stat.h> #include <sys/time.h> #include <sys/types.h> #include <sys/utsname.h> #include <sys/wait.h> Loading Loading @@ -151,6 +152,24 @@ static void SetSigChldHandler() { } } // Resets nice priority for zygote process. Zygote priority can be set // to high value during boot phase to speed it up. We want to ensure // zygote is running at normal priority before childs are forked from it. // // This ends up being called repeatedly before each fork(), but there's // no real harm in that. static void ResetNicePriority(JNIEnv* env) { errno = 0; int prio = getpriority(PRIO_PROCESS, 0); if (prio == -1 && errno != 0) { ALOGW("getpriority failed: %s\n", strerror(errno)); } if (prio != 0 && setpriority(PRIO_PROCESS, 0, 0) != 0) { ALOGE("setpriority(%d, 0, 0) failed: %s", PRIO_PROCESS, strerror(errno)); RuntimeAbort(env, __LINE__, "setpriority failed"); } } // Sets the SIGCHLD handler back to default behavior in zygote children. static void UnsetSigChldHandler() { struct sigaction sa; Loading Loading @@ -448,6 +467,8 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra SetForkLoad(true); #endif ResetNicePriority(env); pid_t pid = fork(); if (pid == 0) { Loading Loading @@ -692,4 +713,3 @@ int register_com_android_internal_os_Zygote(JNIEnv* env) { return RegisterMethodsOrDie(env, "com/android/internal/os/Zygote", gMethods, NELEM(gMethods)); } } // namespace android