Elliott Hughes | 01158d7 | 2011-09-19 19:47:10 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 17 | #include <grp.h> |
Elliott Hughes | 01158d7 | 2011-09-19 19:47:10 -0700 | [diff] [blame] | 18 | #include <paths.h> |
| 19 | #include <stdlib.h> |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 20 | #include <sys/prctl.h> |
| 21 | #include <sys/types.h> |
| 22 | #include <sys/wait.h> |
Elliott Hughes | 01158d7 | 2011-09-19 19:47:10 -0700 | [diff] [blame] | 23 | #include <unistd.h> |
| 24 | |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 25 | #include "debugger.h" |
| 26 | #include "jni_internal.h" |
| 27 | #include "JniConstants.h" |
| 28 | #include "JNIHelp.h" |
| 29 | #include "ScopedLocalRef.h" |
| 30 | #include "ScopedPrimitiveArray.h" |
| 31 | #include "ScopedUtfChars.h" |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 32 | #include "thread.h" |
| 33 | |
Elliott Hughes | 01158d7 | 2011-09-19 19:47:10 -0700 | [diff] [blame] | 34 | namespace art { |
| 35 | |
| 36 | namespace { |
| 37 | |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 38 | static pid_t gSystemServerPid = 0; |
| 39 | |
Elliott Hughes | 01158d7 | 2011-09-19 19:47:10 -0700 | [diff] [blame] | 40 | void Zygote_nativeExecShell(JNIEnv* env, jclass, jstring javaCommand) { |
| 41 | ScopedUtfChars command(env, javaCommand); |
| 42 | if (command.c_str() == NULL) { |
| 43 | return; |
| 44 | } |
Elliott Hughes | c1f143d | 2011-12-01 17:31:10 -0800 | [diff] [blame] | 45 | const char* argp[] = {_PATH_BSHELL, "-c", command.c_str(), NULL}; |
Elliott Hughes | 01158d7 | 2011-09-19 19:47:10 -0700 | [diff] [blame] | 46 | LOG(INFO) << "Exec: " << argp[0] << ' ' << argp[1] << ' ' << argp[2]; |
| 47 | |
| 48 | execv(_PATH_BSHELL, (char**)argp); |
| 49 | exit(127); |
| 50 | } |
| 51 | |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 52 | |
| 53 | // This signal handler is for zygote mode, since the zygote must reap its children |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 54 | void SigChldHandler(int s) { |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 55 | pid_t pid; |
| 56 | int status; |
| 57 | |
| 58 | while ((pid = waitpid(-1, &status, WNOHANG)) > 0) { |
| 59 | // Log process-death status that we care about. In general it is |
| 60 | // not safe to call LOG(...) from a signal handler because of |
| 61 | // possible reentrancy. However, we know a priori that the |
| 62 | // current implementation of LOG() is safe to call from a SIGCHLD |
| 63 | // handler in the zygote process. If the LOG() implementation |
| 64 | // changes its locking strategy or its use of syscalls within the |
| 65 | // lazy-init critical section, its use here may become unsafe. |
| 66 | if (WIFEXITED(status)) { |
| 67 | if (WEXITSTATUS(status)) { |
| 68 | LOG(INFO) << "Process " << pid << " exited cleanly (" << WEXITSTATUS(status) << ")"; |
| 69 | } else if (false) { |
| 70 | LOG(INFO) << "Process " << pid << " exited cleanly (" << WEXITSTATUS(status) << ")"; |
| 71 | } |
| 72 | } else if (WIFSIGNALED(status)) { |
| 73 | if (WTERMSIG(status) != SIGKILL) { |
| 74 | LOG(INFO) << "Process " << pid << " terminated by signal (" << WTERMSIG(status) << ")"; |
| 75 | } else if (false) { |
| 76 | LOG(INFO) << "Process " << pid << " terminated by signal (" << WTERMSIG(status) << ")"; |
| 77 | } |
| 78 | #ifdef WCOREDUMP |
| 79 | if (WCOREDUMP(status)) { |
| 80 | LOG(INFO) << "Process " << pid << " dumped core"; |
| 81 | } |
| 82 | #endif /* ifdef WCOREDUMP */ |
| 83 | } |
| 84 | |
| 85 | // If the just-crashed process is the system_server, bring down zygote |
| 86 | // so that it is restarted by init and system server will be restarted |
| 87 | // from there. |
| 88 | if (pid == gSystemServerPid) { |
Brian Carlstrom | 6a4be3a | 2011-10-20 16:34:03 -0700 | [diff] [blame] | 89 | LOG(ERROR) << "Exit zygote because system server (" << pid << ") has terminated"; |
| 90 | kill(getpid(), SIGKILL); |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 91 | } |
| 92 | } |
| 93 | |
| 94 | if (pid < 0) { |
| 95 | PLOG(WARNING) << "Zygote SIGCHLD error in waitpid"; |
| 96 | } |
| 97 | } |
| 98 | |
| 99 | // configure sigchld handler for the zygote process This is configured |
| 100 | // very late, because earlier in the runtime we may fork() and exec() |
| 101 | // other processes, and we want to waitpid() for those rather than |
| 102 | // have them be harvested immediately. |
| 103 | // |
| 104 | // This ends up being called repeatedly before each fork(), but there's |
| 105 | // no real harm in that. |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 106 | void SetSigChldHandler() { |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 107 | struct sigaction sa; |
| 108 | memset(&sa, 0, sizeof(sa)); |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 109 | sa.sa_handler = SigChldHandler; |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 110 | |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame] | 111 | int err = sigaction(SIGCHLD, &sa, NULL); |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 112 | if (err < 0) { |
| 113 | PLOG(WARNING) << "Error setting SIGCHLD handler"; |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | // Set the SIGCHLD handler back to default behavior in zygote children |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 118 | void UnsetSigChldHandler() { |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 119 | struct sigaction sa; |
| 120 | memset(&sa, 0, sizeof(sa)); |
| 121 | sa.sa_handler = SIG_DFL; |
| 122 | |
Elliott Hughes | 362f9bc | 2011-10-17 18:56:41 -0700 | [diff] [blame] | 123 | int err = sigaction(SIGCHLD, &sa, NULL); |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 124 | if (err < 0) { |
| 125 | PLOG(WARNING) << "Error unsetting SIGCHLD handler"; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | // Calls POSIX setgroups() using the int[] object as an argument. |
| 130 | // A NULL argument is tolerated. |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 131 | int SetGids(JNIEnv* env, jintArray javaGids) { |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 132 | if (javaGids == NULL) { |
| 133 | return 0; |
| 134 | } |
| 135 | |
| 136 | COMPILE_ASSERT(sizeof(gid_t) == sizeof(jint), sizeof_gid_and_jint_are_differerent); |
| 137 | ScopedIntArrayRO gids(env, javaGids); |
| 138 | if (gids.get() == NULL) { |
| 139 | return -1; |
| 140 | } |
| 141 | return setgroups(gids.size(), (const gid_t *) &gids[0]); |
| 142 | } |
| 143 | |
| 144 | // Sets the resource limits via setrlimit(2) for the values in the |
| 145 | // two-dimensional array of integers that's passed in. The second dimension |
| 146 | // contains a tuple of length 3: (resource, rlim_cur, rlim_max). NULL is |
| 147 | // treated as an empty array. |
| 148 | // |
| 149 | // -1 is returned on error. |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 150 | int SetRLimits(JNIEnv* env, jobjectArray javaRlimits) { |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 151 | if (javaRlimits == NULL) { |
| 152 | return 0; |
| 153 | } |
| 154 | |
| 155 | struct rlimit rlim; |
| 156 | memset(&rlim, 0, sizeof(rlim)); |
| 157 | |
| 158 | for (int i = 0; i < env->GetArrayLength(javaRlimits); i++) { |
| 159 | ScopedLocalRef<jobject> javaRlimitObject(env, env->GetObjectArrayElement(javaRlimits, i)); |
| 160 | ScopedIntArrayRO javaRlimit(env, reinterpret_cast<jintArray>(javaRlimitObject.get())); |
| 161 | if (javaRlimit.size() != 3) { |
| 162 | LOG(ERROR) << "rlimits array must have a second dimension of size 3"; |
| 163 | return -1; |
| 164 | } |
| 165 | |
| 166 | rlim.rlim_cur = javaRlimit[1]; |
| 167 | rlim.rlim_max = javaRlimit[2]; |
| 168 | |
| 169 | int err = setrlimit(javaRlimit[0], &rlim); |
| 170 | if (err < 0) { |
| 171 | return -1; |
| 172 | } |
| 173 | } |
| 174 | return 0; |
| 175 | } |
| 176 | |
Elliott Hughes | 3d30d9b | 2011-12-07 17:35:48 -0800 | [diff] [blame] | 177 | void SetCapabilities(int64_t permitted, int64_t effective) { |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 178 | #ifdef HAVE_ANDROID_OS |
| 179 | struct __user_cap_header_struct capheader; |
| 180 | struct __user_cap_data_struct capdata; |
| 181 | |
| 182 | memset(&capheader, 0, sizeof(capheader)); |
| 183 | memset(&capdata, 0, sizeof(capdata)); |
| 184 | |
| 185 | capheader.version = _LINUX_CAPABILITY_VERSION; |
| 186 | capheader.pid = 0; |
| 187 | |
| 188 | capdata.effective = effective; |
| 189 | capdata.permitted = permitted; |
| 190 | |
| 191 | if (capset(&capheader, &capdata) != 0) { |
Elliott Hughes | 3d30d9b | 2011-12-07 17:35:48 -0800 | [diff] [blame] | 192 | PLOG(FATAL) << "capset(" << permitted << ", " << effective << ") failed"; |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 193 | } |
| 194 | #endif /*HAVE_ANDROID_OS*/ |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 195 | } |
| 196 | |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 197 | void EnableDebugFeatures(uint32_t debug_flags) { |
| 198 | // Must match values in dalvik.system.Zygote. |
| 199 | enum { |
| 200 | DEBUG_ENABLE_DEBUGGER = 1, |
| 201 | DEBUG_ENABLE_CHECKJNI = 1 << 1, |
| 202 | DEBUG_ENABLE_ASSERT = 1 << 2, |
| 203 | DEBUG_ENABLE_SAFEMODE = 1 << 3, |
| 204 | DEBUG_ENABLE_JNI_LOGGING = 1 << 4, |
| 205 | }; |
| 206 | |
| 207 | if ((debug_flags & DEBUG_ENABLE_CHECKJNI) != 0) { |
| 208 | Runtime* runtime = Runtime::Current(); |
| 209 | JavaVMExt* vm = runtime->GetJavaVM(); |
| 210 | if (!vm->check_jni) { |
| 211 | LOG(DEBUG) << "Late-enabling -Xcheck:jni"; |
| 212 | vm->EnableCheckJni(); |
| 213 | // There's only one thread running at this point, so only one JNIEnv to fix up. |
| 214 | Thread::Current()->GetJniEnv()->EnableCheckJni(); |
| 215 | } else { |
| 216 | LOG(DEBUG) << "Not late-enabling -Xcheck:jni (already on)"; |
| 217 | } |
| 218 | debug_flags &= ~DEBUG_ENABLE_CHECKJNI; |
| 219 | } |
| 220 | |
| 221 | if ((debug_flags & DEBUG_ENABLE_JNI_LOGGING) != 0) { |
| 222 | Runtime::Current()->GetJavaVM()->log_third_party_jni = true; |
| 223 | debug_flags &= ~DEBUG_ENABLE_JNI_LOGGING; |
| 224 | } |
| 225 | |
| 226 | Dbg::SetJdwpAllowed((debug_flags & DEBUG_ENABLE_DEBUGGER) != 0); |
| 227 | #ifdef HAVE_ANDROID_OS |
| 228 | if ((debug_flags & DEBUG_ENABLE_DEBUGGER) != 0) { |
| 229 | /* To let a non-privileged gdbserver attach to this |
| 230 | * process, we must set its dumpable bit flag. However |
| 231 | * we are not interested in generating a coredump in |
| 232 | * case of a crash, so also set the coredump size to 0 |
| 233 | * to disable that |
| 234 | */ |
| 235 | if (prctl(PR_SET_DUMPABLE, 1, 0, 0, 0) < 0) { |
| 236 | PLOG(ERROR) << "could not set dumpable bit flag for pid " << getpid(); |
| 237 | } else { |
| 238 | struct rlimit rl; |
| 239 | rl.rlim_cur = 0; |
| 240 | rl.rlim_max = RLIM_INFINITY; |
| 241 | if (setrlimit(RLIMIT_CORE, &rl) < 0) { |
| 242 | PLOG(ERROR) << "could not disable core file generation for pid " << getpid(); |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | #endif |
| 247 | debug_flags &= ~DEBUG_ENABLE_DEBUGGER; |
| 248 | |
| 249 | // These two are for backwards compatibility with Dalvik. |
| 250 | debug_flags &= ~DEBUG_ENABLE_ASSERT; |
| 251 | debug_flags &= ~DEBUG_ENABLE_SAFEMODE; |
| 252 | |
| 253 | if (debug_flags != 0) { |
| 254 | LOG(ERROR) << StringPrintf("Unknown bits set in debug_flags: %#x", debug_flags); |
| 255 | } |
| 256 | } |
| 257 | |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 258 | #ifdef HAVE_ANDROID_OS |
| 259 | extern "C" int gMallocLeakZygoteChild; |
| 260 | #endif |
| 261 | |
| 262 | // Utility routine to fork zygote and specialize the child process. |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 263 | pid_t ForkAndSpecializeCommon(JNIEnv* env, uid_t uid, gid_t gid, jintArray javaGids, |
| 264 | jint debug_flags, jobjectArray javaRlimits, |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 265 | jlong permittedCapabilities, jlong effectiveCapabilities) |
| 266 | { |
| 267 | Runtime* runtime = Runtime::Current(); |
| 268 | CHECK(runtime->IsZygote()) << "runtime instance not started with -Xzygote"; |
| 269 | if (false) { // TODO: do we need do anything special like !dvmGcPreZygoteFork()? |
| 270 | LOG(FATAL) << "pre-fork heap failed"; |
| 271 | } |
| 272 | |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 273 | SetSigChldHandler(); |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 274 | |
| 275 | // Grab thread before fork potentially makes Thread::pthread_key_self_ unusable. |
| 276 | Thread* self = Thread::Current(); |
| 277 | |
| 278 | // dvmDumpLoaderStats("zygote"); // TODO: ? |
| 279 | pid_t pid = fork(); |
| 280 | |
| 281 | if (pid == 0) { |
| 282 | // The child process |
| 283 | |
| 284 | #ifdef HAVE_ANDROID_OS |
| 285 | gMallocLeakZygoteChild = 1; |
| 286 | |
| 287 | // keep caps across UID change, unless we're staying root */ |
| 288 | if (uid != 0) { |
| 289 | int err = prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0); |
| 290 | if (err < 0) { |
| 291 | PLOG(FATAL) << "cannot PR_SET_KEEPCAPS"; |
| 292 | } |
| 293 | } |
| 294 | #endif // HAVE_ANDROID_OS |
| 295 | |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 296 | int err = SetGids(env, javaGids); |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 297 | if (err < 0) { |
Elliott Hughes | 3d30d9b | 2011-12-07 17:35:48 -0800 | [diff] [blame] | 298 | PLOG(FATAL) << "setgroups failed"; |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 301 | err = SetRLimits(env, javaRlimits); |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 302 | if (err < 0) { |
Elliott Hughes | 3d30d9b | 2011-12-07 17:35:48 -0800 | [diff] [blame] | 303 | PLOG(FATAL) << "setrlimit failed"; |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 304 | } |
| 305 | |
| 306 | err = setgid(gid); |
| 307 | if (err < 0) { |
Elliott Hughes | 3d30d9b | 2011-12-07 17:35:48 -0800 | [diff] [blame] | 308 | PLOG(FATAL) << "setgid(" << gid << ") failed"; |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | err = setuid(uid); |
| 312 | if (err < 0) { |
Elliott Hughes | 3d30d9b | 2011-12-07 17:35:48 -0800 | [diff] [blame] | 313 | PLOG(FATAL) << "setuid(" << uid << ") failed"; |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 314 | } |
| 315 | |
Elliott Hughes | 3d30d9b | 2011-12-07 17:35:48 -0800 | [diff] [blame] | 316 | SetCapabilities(permittedCapabilities, effectiveCapabilities); |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 317 | |
| 318 | // Our system thread ID, etc, has changed so reset Thread state. |
| 319 | self->InitAfterFork(); |
| 320 | |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 321 | EnableDebugFeatures(debug_flags); |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 322 | |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 323 | UnsetSigChldHandler(); |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 324 | runtime->DidForkFromZygote(); |
| 325 | } else if (pid > 0) { |
| 326 | // the parent process |
| 327 | } |
| 328 | return pid; |
| 329 | } |
| 330 | |
Brian Carlstrom | a9f1978 | 2011-10-13 00:14:47 -0700 | [diff] [blame] | 331 | jint Zygote_nativeForkAndSpecialize(JNIEnv* env, jclass, jint uid, jint gid, jintArray gids, |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 332 | jint debug_flags, jobjectArray rlimits) { |
| 333 | return ForkAndSpecializeCommon(env, uid, gid, gids, debug_flags, rlimits, 0, 0); |
Brian Carlstrom | a9f1978 | 2011-10-13 00:14:47 -0700 | [diff] [blame] | 334 | } |
| 335 | |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 336 | jint Zygote_nativeForkSystemServer(JNIEnv* env, jclass, uid_t uid, gid_t gid, jintArray gids, |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 337 | jint debug_flags, jobjectArray rlimits, |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 338 | jlong permittedCapabilities, jlong effectiveCapabilities) { |
Elliott Hughes | 4ffd313 | 2011-10-24 12:06:42 -0700 | [diff] [blame] | 339 | pid_t pid = ForkAndSpecializeCommon(env, uid, gid, gids, |
| 340 | debug_flags, rlimits, |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 341 | permittedCapabilities, effectiveCapabilities); |
| 342 | if (pid > 0) { |
| 343 | // The zygote process checks whether the child process has died or not. |
| 344 | LOG(INFO) << "System server process " << pid << " has been created"; |
| 345 | gSystemServerPid = pid; |
| 346 | // There is a slight window that the system server process has crashed |
| 347 | // but it went unnoticed because we haven't published its pid yet. So |
| 348 | // we recheck here just to make sure that all is well. |
| 349 | int status; |
| 350 | if (waitpid(pid, &status, WNOHANG) == pid) { |
| 351 | LOG(FATAL) << "System server process " << pid << " has died. Restarting Zygote!"; |
| 352 | } |
| 353 | } |
| 354 | return pid; |
| 355 | } |
| 356 | |
Elliott Hughes | 01158d7 | 2011-09-19 19:47:10 -0700 | [diff] [blame] | 357 | static JNINativeMethod gMethods[] = { |
| 358 | NATIVE_METHOD(Zygote, nativeExecShell, "(Ljava/lang/String;)V"), |
| 359 | //NATIVE_METHOD(Zygote, nativeFork, "()I"), |
Brian Carlstrom | a9f1978 | 2011-10-13 00:14:47 -0700 | [diff] [blame] | 360 | NATIVE_METHOD(Zygote, nativeForkAndSpecialize, "(II[II[[I)I"), |
Brian Carlstrom | caabb1b | 2011-10-11 18:09:13 -0700 | [diff] [blame] | 361 | NATIVE_METHOD(Zygote, nativeForkSystemServer, "(II[II[[IJJ)I"), |
Elliott Hughes | 01158d7 | 2011-09-19 19:47:10 -0700 | [diff] [blame] | 362 | }; |
| 363 | |
| 364 | } // namespace |
| 365 | |
| 366 | void register_dalvik_system_Zygote(JNIEnv* env) { |
| 367 | jniRegisterNativeMethods(env, "dalvik/system/Zygote", gMethods, NELEM(gMethods)); |
| 368 | } |
| 369 | |
| 370 | } // namespace art |