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 | |
| 17 | #include "jni_internal.h" |
| 18 | #include "JNIHelp.h" |
| 19 | #include "ScopedUtfChars.h" |
| 20 | |
| 21 | #include "JniConstants.h" // Last to avoid problems with LOG redefinition. |
| 22 | |
| 23 | #include <paths.h> |
| 24 | #include <stdlib.h> |
| 25 | #include <unistd.h> |
| 26 | |
| 27 | namespace art { |
| 28 | |
| 29 | namespace { |
| 30 | |
| 31 | void Zygote_nativeExecShell(JNIEnv* env, jclass, jstring javaCommand) { |
| 32 | ScopedUtfChars command(env, javaCommand); |
| 33 | if (command.c_str() == NULL) { |
| 34 | return; |
| 35 | } |
| 36 | const char *argp[] = {_PATH_BSHELL, "-c", command.c_str(), NULL}; |
| 37 | LOG(INFO) << "Exec: " << argp[0] << ' ' << argp[1] << ' ' << argp[2]; |
| 38 | |
| 39 | execv(_PATH_BSHELL, (char**)argp); |
| 40 | exit(127); |
| 41 | } |
| 42 | |
| 43 | static JNINativeMethod gMethods[] = { |
| 44 | NATIVE_METHOD(Zygote, nativeExecShell, "(Ljava/lang/String;)V"), |
| 45 | //NATIVE_METHOD(Zygote, nativeFork, "()I"), |
| 46 | //NATIVE_METHOD(Zygote, nativeForkAndSpecialize, "(II[II[[I)I"), |
| 47 | //NATIVE_METHOD(Zygote, nativeForkSystemServer, "(II[II[[IJJ)I"), |
| 48 | }; |
| 49 | |
| 50 | } // namespace |
| 51 | |
| 52 | void register_dalvik_system_Zygote(JNIEnv* env) { |
| 53 | jniRegisterNativeMethods(env, "dalvik/system/Zygote", gMethods, NELEM(gMethods)); |
| 54 | } |
| 55 | |
| 56 | } // namespace art |