--- old/src/solaris/classes/java/lang/UNIXProcess.java.linux Thu Jul 25 16:50:07 2013 +++ new/src/solaris/classes/java/lang/UNIXProcess.java.linux Thu Jul 25 16:50:05 2013 @@ -64,11 +64,50 @@ private /* final */ InputStream stdout; private /* final */ InputStream stderr; + private static String javahome; + private static String helperpath; + + enum LaunchMechanism { + fork(1), + vfork(3); + + private int value; + LaunchMechanism(int x) {value = x;} + }; + + /* default is VFORK on Linux */ + private static LaunchMechanism launchMechanism; + + static { + AccessController.doPrivileged(new PrivilegedAction() { + public Void run() { + String javahome = System.getProperty("java.home"); + String osArch = System.getProperty("os.arch"); + + helperpath = javahome + "/lib/" + osArch + "/jspawnhelper"; + String s = System.getProperty( + "jdk.lang.Process.launchMechanism", "vfork"); + + try { + launchMechanism = LaunchMechanism.valueOf(s); + } catch (IllegalArgumentException e) { + throw new Error(s + " is not a supported " + + "process launch mechanism on this platform."); + } + return null; + } + }); + } + /* this is for the reaping thread */ private native int waitForProcessExit(int pid); /** - * Create a process using fork(2) and exec(2). + * 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, @@ -81,7 +120,7 @@ * output. * @return the pid of the subprocess */ - private native int forkAndExec(byte[] prog, + private native int forkAndExec(int mode, byte[] prog, byte[] argBlock, int argc, byte[] envBlock, int envc, byte[] dir, @@ -133,7 +172,8 @@ final boolean redirectErrorStream) throws IOException { - pid = forkAndExec(prog, + pid = forkAndExec(launchMechanism.value, + prog, argBlock, argc, envBlock, envc, dir,