From 1480dc3e97b661f5bfa3a5c2fbce72385b8d2be6 Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Wed, 9 Nov 2016 09:25:03 +0000 Subject: [PATCH] Zygote: Unblock SIGCHLD in the parent after fork. Follow up to change e9a525829a354c92983a. Allows the zygote to receive SIGCHLD again and prevents the zygote from getting into a zombie state if it's killed. Change-Id: I81fde39a2dd32eaf7d8b397672d3165a4eb945e1 Contributed-By: rhed_jao Bug: 32693692 Test: manual --- core/jni/com_android_internal_os_Zygote.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/core/jni/com_android_internal_os_Zygote.cpp b/core/jni/com_android_internal_os_Zygote.cpp index bba3d76492260..fc85b4bd37342 100644 --- a/core/jni/com_android_internal_os_Zygote.cpp +++ b/core/jni/com_android_internal_os_Zygote.cpp @@ -628,6 +628,12 @@ static pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArra } } else if (pid > 0) { // the parent process + + // We blocked SIGCHLD prior to a fork, we unblock it here. + if (sigprocmask(SIG_UNBLOCK, &sigchld, nullptr) == -1) { + ALOGE("sigprocmask(SIG_SETMASK, { SIGCHLD }) failed: %s", strerror(errno)); + RuntimeAbort(env, __LINE__, "Call to sigprocmask(SIG_UNBLOCK, { SIGCHLD }) failed."); + } } return pid; }