OSDN Git Service

Add Zygote.startChildZygote() to fork a new process that itself is a zygote.
authorRobert Sesek <rsesek@google.com>
Mon, 12 Feb 2018 23:46:01 +0000 (18:46 -0500)
committerRobert Sesek <rsesek@google.com>
Fri, 16 Feb 2018 19:17:41 +0000 (14:17 -0500)
commitd0a190df8a04e10a6705148c02c5c4859ad75b70
tree35ce966a8d98e6a56113fd1f7a8dc7e299fe22ee
parent2c8456b22e7d9c66de9ae70f0a79582499a7b61d
Add Zygote.startChildZygote() to fork a new process that itself is a zygote.

This adds a new --start-child-zygote argument that instructs the main
zygote to create a new child process that will also be a zygote. The
system_server generates a random name in the abstract socket namespace
for it and the child-zygote to communicate over, and that is passed as
an argument to the new process.

A child-zygote bypasses the normal post-fork-child of the zygote process
in order to preserve itself as a zygote. This means not starting the
Binder threadpool nor launching into ActivityThread. Instead, a
child-zygote calls into its own main function. The main function runs a
ZygoteServer select loop, listening on the socket name specified by the
system_server when it was forked.

Unlike the system zygotes, a child-zygote can be killed without bringing
down the system. Killing a child-zygote will not terminate its child
processes, which will be reparented to init for reaping when they
eventually exit.

Bug: 63749735
Test: m (with multi-project commits landed)
Change-Id: I3e7ebbdba498f8fec1d84cdf927dc43a92be4b68
core/java/android/os/ChildZygoteProcess.java [new file with mode: 0644]
core/java/android/os/ZygoteProcess.java
core/java/com/android/internal/os/RuntimeInit.java
core/java/com/android/internal/os/WebViewZygoteInit.java
core/java/com/android/internal/os/Zygote.java
core/java/com/android/internal/os/ZygoteConnection.java
core/java/com/android/internal/os/ZygoteInit.java
core/java/com/android/internal/os/ZygoteServer.java
core/jni/com_android_internal_os_Zygote.cpp
core/jni/fd_utils.cpp