src/solaris/classes/java/lang/UNIXProcess.java.linux

Print this page

        

*** 62,76 **** private /* final */ OutputStream stdin; private /* final */ InputStream stdout; private /* final */ InputStream stderr; /* this is for the reaping thread */ private native int waitForProcessExit(int pid); /** ! * Create a process using fork(2) and exec(2). * * @param fds an array of three file descriptors. * Indexes 0, 1, and 2 correspond to standard input, * standard output and standard error, respectively. On * input, a value of -1 means to create a pipe to connect --- 62,109 ---- private /* final */ OutputStream stdin; private /* final */ InputStream stdout; private /* final */ InputStream stderr; + private static String javahome; + private static String helperpath; + + enum LaunchMechanism { + CLONE(1), FORK(2), + VFORK(3), SPAWN(4); + + private int value; + LaunchMechanism(int x) {value = x;} + }; + + /* default is VFORK on Linux */ + private static LaunchMechanism launchMechanism = LaunchMechanism.VFORK; + + static { + AccessController.doPrivileged(new PrivilegedAction<Void>() { + public Void run() { + String javahome = System.getProperty("java.home"); + + helperpath = javahome + "/bin/jprochelper"; + String s = System.getProperty("java.lang.useFork"); + if (s != null) { + launchMechanism = LaunchMechanism.FORK; + } + return null; + } + }); + } + /* this is for the reaping thread */ private native int waitForProcessExit(int pid); /** ! * Create a process. Depending on the mode flag, this is done by ! * one of the following mechanisms. ! * - fork(2) and exec(2) ! * - clone(2) and exec(2) ! * - vfork(2) and exec(2) * * @param fds an array of three file descriptors. * Indexes 0, 1, and 2 correspond to standard input, * standard output and standard error, respectively. On * input, a value of -1 means to create a pipe to connect
*** 79,89 **** * pipe which has been created. An element of this array * is -1 on input if and only if it is <em>not</em> -1 on * output. * @return the pid of the subprocess */ ! private native int forkAndExec(byte[] prog, byte[] argBlock, int argc, byte[] envBlock, int envc, byte[] dir, int[] fds, boolean redirectErrorStream) --- 112,122 ---- * pipe which has been created. An element of this array * is -1 on input if and only if it is <em>not</em> -1 on * output. * @return the pid of the subprocess */ ! private native int forkAndExec(int mode, byte[] prog, byte[] argBlock, int argc, byte[] envBlock, int envc, byte[] dir, int[] fds, boolean redirectErrorStream)
*** 131,141 **** final byte[] dir, final int[] fds, final boolean redirectErrorStream) throws IOException { ! pid = forkAndExec(prog, argBlock, argc, envBlock, envc, dir, fds, redirectErrorStream); --- 164,175 ---- final byte[] dir, final int[] fds, final boolean redirectErrorStream) throws IOException { ! pid = forkAndExec(launchMechanism.value, ! prog, argBlock, argc, envBlock, envc, dir, fds, redirectErrorStream);