Zygote: Add fdsToIgnore
Add file descriptors that should be ignored in the file descriptor table check. Use this to ignore the pipe file descriptors when starting an app with invoke-with (wrapper). Bug: 32607405 Test: m Test: Device boots Test: Apps start Test: adb root && adb shell setprop wrap.com.android.calculator2 logwrapper && adb shell am start -S -n com.android.calculator2/.Calculator Change-Id: I4a30dfc9382d3172cc815bd41b17a123799354f6
This commit is contained in:
@@ -85,6 +85,9 @@ public final class Zygote {
|
||||
* file descriptor numbers that are to be closed by the child
|
||||
* (and replaced by /dev/null) after forking. An integer value
|
||||
* of -1 in any entry in the array means "ignore this one".
|
||||
* @param fdsToIgnore null-ok an array of ints, either null or holding
|
||||
* one or more POSIX file descriptor numbers that are to be ignored
|
||||
* in the file descriptor table check.
|
||||
* @param instructionSet null-ok the instruction set to use.
|
||||
* @param appDataDir null-ok the data directory of the app.
|
||||
*
|
||||
@@ -93,11 +96,11 @@ public final class Zygote {
|
||||
*/
|
||||
public static int forkAndSpecialize(int uid, int gid, int[] gids, int debugFlags,
|
||||
int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose,
|
||||
String instructionSet, String appDataDir) {
|
||||
int[] fdsToIgnore, String instructionSet, String appDataDir) {
|
||||
VM_HOOKS.preFork();
|
||||
int pid = nativeForkAndSpecialize(
|
||||
uid, gid, gids, debugFlags, rlimits, mountExternal, seInfo, niceName, fdsToClose,
|
||||
instructionSet, appDataDir);
|
||||
fdsToIgnore, instructionSet, appDataDir);
|
||||
// Enable tracing as soon as possible for the child process.
|
||||
if (pid == 0) {
|
||||
Trace.setTracingEnabled(true);
|
||||
@@ -111,7 +114,7 @@ public final class Zygote {
|
||||
|
||||
native private static int nativeForkAndSpecialize(int uid, int gid, int[] gids,int debugFlags,
|
||||
int[][] rlimits, int mountExternal, String seInfo, String niceName, int[] fdsToClose,
|
||||
String instructionSet, String appDataDir);
|
||||
int[] fdsToIgnore, String instructionSet, String appDataDir);
|
||||
|
||||
/**
|
||||
* Special method to start the system server process. In addition to the
|
||||
|
||||
@@ -193,11 +193,14 @@ class ZygoteConnection {
|
||||
rlimits = parsedArgs.rlimits.toArray(intArray2d);
|
||||
}
|
||||
|
||||
int[] fdsToIgnore = null;
|
||||
|
||||
if (parsedArgs.invokeWith != null) {
|
||||
FileDescriptor[] pipeFds = Os.pipe2(O_CLOEXEC);
|
||||
childPipeFd = pipeFds[1];
|
||||
serverPipeFd = pipeFds[0];
|
||||
Os.fcntlInt(childPipeFd, F_SETFD, 0);
|
||||
fdsToIgnore = new int[] { childPipeFd.getInt$(), serverPipeFd.getInt$() };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,7 +233,7 @@ class ZygoteConnection {
|
||||
|
||||
pid = Zygote.forkAndSpecialize(parsedArgs.uid, parsedArgs.gid, parsedArgs.gids,
|
||||
parsedArgs.debugFlags, rlimits, parsedArgs.mountExternal, parsedArgs.seInfo,
|
||||
parsedArgs.niceName, fdsToClose, parsedArgs.instructionSet,
|
||||
parsedArgs.niceName, fdsToClose, fdsToIgnore, parsedArgs.instructionSet,
|
||||
parsedArgs.appDataDir);
|
||||
} catch (ErrnoException ex) {
|
||||
logAndPrintError(newStderr, "Exception creating pipe", ex);
|
||||
|
||||
Reference in New Issue
Block a user