public class

Zygote

extends Object
java.lang.Object
   ↳ dalvik.system.Zygote

Class Overview

Provides access to the Dalvik "zygote" feature, which allows a VM instance to be partially initialized and then fork()'d from the partially initialized state.

Summary

Constants
int DEBUG_ENABLE_ASSERT enable Java programming language "assert" statements
int DEBUG_ENABLE_CHECKJNI enable JNI checks
int DEBUG_ENABLE_DEBUGGER enable debugging over JDWP
Public Methods
static int fork()
Forks a new Zygote instance, but does not leave the zygote mode.
static int forkAndSpecialize(int uid, int gid, int[] gids, int debugFlags, int[][] rlimits)
Forks a new VM instance.
static int forkAndSpecialize(int uid, int gid, int[] gids, boolean enableDebugger, int[][] rlimits)
This method is deprecated. use forkAndSpecialize(int, int, int[], int, int[][])
static int forkSystemServer(int uid, int gid, int[] gids, int debugFlags, int[][] rlimits)
Special method to start the system server process.
static int forkSystemServer(int uid, int gid, int[] gids, boolean enableDebugger, int[][] rlimits)
This method is deprecated. use forkSystemServer(int, int, int[], int, int[][])
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int DEBUG_ENABLE_ASSERT

enable Java programming language "assert" statements

Constant Value: 4 (0x00000004)

public static final int DEBUG_ENABLE_CHECKJNI

enable JNI checks

Constant Value: 2 (0x00000002)

public static final int DEBUG_ENABLE_DEBUGGER

enable debugging over JDWP

Constant Value: 1 (0x00000001)

Public Methods

public static int fork ()

Forks a new Zygote instance, but does not leave the zygote mode. The current VM must have been started with the -Xzygote flag. The new child is expected to eventually call forkAndSpecialize()

Returns
  • 0 if this is the child, pid of the child if this is the parent, or -1 on error

public static int forkAndSpecialize (int uid, int gid, int[] gids, int debugFlags, int[][] rlimits)

Forks a new VM instance. The current VM must have been started with the -Xzygote flag. NOTE: new instance keeps all root capabilities. The new process is expected to call capset().

Parameters
uid the UNIX uid that the new process should setuid() to after fork()ing and and before spawning any threads.
gid the UNIX gid that the new process should setgid() to after fork()ing and and before spawning any threads.
gids null-ok; a list of UNIX gids that the new process should setgroups() to after fork and before spawning any threads.
debugFlags bit flags that enable debugging features.
rlimits null-ok an array of rlimit tuples, with the second dimension having a length of 3 and representing (resource, rlim_cur, rlim_max). These are set via the posix setrlimit(2) call.
Returns
  • 0 if this is the child, pid of the child if this is the parent, or -1 on error.

public static int forkAndSpecialize (int uid, int gid, int[] gids, boolean enableDebugger, int[][] rlimits)

This method is deprecated.use forkAndSpecialize(int, int, int[], int, int[][])

Forks a new VM instance.

public static int forkSystemServer (int uid, int gid, int[] gids, int debugFlags, int[][] rlimits)

Special method to start the system server process. In addition to the common actions performed in forkAndSpecialize, the pid of the child process is recorded such that the death of the child process will cause zygote to exit.

Parameters
uid the UNIX uid that the new process should setuid() to after fork()ing and and before spawning any threads.
gid the UNIX gid that the new process should setgid() to after fork()ing and and before spawning any threads.
gids null-ok; a list of UNIX gids that the new process should setgroups() to after fork and before spawning any threads.
debugFlags bit flags that enable debugging features.
rlimits null-ok an array of rlimit tuples, with the second dimension having a length of 3 and representing (resource, rlim_cur, rlim_max). These are set via the posix setrlimit(2) call.
Returns
  • 0 if this is the child, pid of the child if this is the parent, or -1 on error.

public static int forkSystemServer (int uid, int gid, int[] gids, boolean enableDebugger, int[][] rlimits)

This method is deprecated.use forkSystemServer(int, int, int[], int, int[][])

Special method to start the system server process.