libcutils/zygote.c
int zygote_run_oneshot(int sendStdio, int argc, const char **argv) 
{
    int fd = -1;
    int err;
    int i;
    int retries;
    int pid;
    const char **newargv = argv;
    const int newargc = argc;

    for (retries = 0; (fd < 0) && (retries < ZYGOTE_RETRY_COUNT); retries++) {
        if (retries > 0) { 
            struct timespec ts;

            memset(&ts, 0, sizeof(ts));
            ts.tv_nsec = ZYGOTE_RETRY_MILLIS * 1000 * 1000;

            do {
                err = nanosleep (&ts, &ts);
            } while (err < 0 && errno == EINTR);
        }
        fd = socket_local_client(ZYGOTE_SOCKET, AF_LOCAL, 
                ANDROID_SOCKET_NAMESPACE_RESERVED);
    }

    if (fd < 0) {
        return -1;
    }

    pid = send_request(fd, 0, newargc, newargv);

    do {
        err = close(fd);
    } while (err < 0 && errno == EINTR);

    return pid;
}
/**
 * Spawns a new dalvik instance via the Zygote process. The non-zygote
 * arguments are passed to com.android.internal.os.RuntimeInit(). The
 * first non-option argument should be a class name in the system class path.
 *
 * The arg list  may start with zygote params such as --set-uid.
 *
 * If sendStdio is non-zero, the current process's stdio file descriptors
 * will be sent and inherited by the spawned process.
 *
 * The pid of the child process is returned, or -1 if an error was 
 * encountered.
 *
 * zygote_run_oneshot waits up to ZYGOTE_RETRY_COUNT * 
 * ZYGOTE_RETRY_MILLIS for the zygote socket to be available.
 */
Spawns a new dalvik instance via the Zygote process. The non-zygote
arguments are passed to com.android.internal.os.RuntimeInit(). The
first non-option argument should be a class name in the system class path.

The arg list  may start with zygote params such as --set-uid.

If sendStdio is non-zero, the current process's stdio file descriptors
will be sent and inherited by the spawned process.

The pid of the child process is returned, or -1 if an error was
encountered.

zygote_run_oneshot waits up to ZYGOTE_RETRY_COUNT
ZYGOTE_RETRY_MILLIS for the zygote socket to be available.
Spawns a new dalvik instance via the Zygote process . The non - zygote arguments are passed to com . android . internal . os . RuntimeInit () . The first non - option argument should be a class name in the system class path . The arg list may start with zygote params such as -- set - uid . If sendStdio is non - zero the current process ' s stdio file descriptors will be sent and inherited by the spawned process . The pid of the child process is returned or - 1 if an error was encountered . zygote_run_oneshot waits up to ZYGOTE_RETRY_COUNT ZYGOTE_RETRY_MILLIS for the zygote socket to be available .
int zygote_run_oneshot(int sendStdio, int argc, const char **argv) 
{
    int fd = -1;
    int err;
    int i;
    int retries;
    int pid;
    const char **newargv = argv;
    const int newargc = argc;
    for (retries = 0; (fd < 0) && (retries < ZYGOTE_RETRY_COUNT); retries++) {
        if (retries > 0) { 
            struct timespec ts;
            memset(&ts, 0, sizeof(ts));
            ts.tv_nsec = ZYGOTE_RETRY_MILLIS * 1000 * 1000;
            do {
                err = nanosleep (&ts, &ts);
            } while (err < 0 && errno == EINTR);
        }
        fd = socket_local_client(ZYGOTE_SOCKET, AF_LOCAL, 
                ANDROID_SOCKET_NAMESPACE_RESERVED);
    }
    if (fd < 0) {
        return -1;
    }
    pid = send_request(fd, 0, newargc, newargv);
    do {
        err = close(fd);
    } while (err < 0 && errno == EINTR);
    return pid;
}
int zygote_run_oneshot ( int sendStdio , int argc , const char * * argv ) { int fd = -1 ; int err ; int i ; int retries ; int pid ; const char * * newargv = argv ; const int newargc = argc ; for ( retries = 0 ; ( fd < 0 ) && ( retries < ZYGOTE_RETRY_COUNT ) ; retries ++ ) { if ( retries > 0 ) { struct timespec ts ; memset ( & ts , 0 , sizeof ( ts ) ) ; ts . tv_nsec = ZYGOTE_RETRY_MILLIS * 1000 * 1000 ; do { err = nanosleep ( & ts , & ts ) ; } while ( err < 0 && errno == EINTR ) ; } fd = socket_local_client ( ZYGOTE_SOCKET , AF_LOCAL , ANDROID_SOCKET_NAMESPACE_RESERVED ) ; } if ( fd < 0 ) { return -1 ; } pid = send_request ( fd , 0 , newargc , newargv ) ; do { err = close ( fd ) ; } while ( err < 0 && errno == EINTR ) ; return pid ; }
Spawns a new dalvik instance via the Zygote process.
Spawns a new dalvik instance via the Zygote process .