--- old/src/solaris/classes/java/lang/UNIXProcess.java.solaris Thu May 21 10:42:51 2009 +++ new/src/solaris/classes/java/lang/UNIXProcess.java.solaris Thu May 21 10:42:50 2009 @@ -48,8 +48,20 @@ /* this is for the reaping thread */ private native int waitForProcessExit(int pid); + private static String javahome; + + static { + javahome = java.security.AccessController.doPrivileged( + new java.security.PrivilegedAction() { public String run() { + return System.getProperty ("java.home"); + }} + ); + } + /** - * Create a process using fork(2) and exec(2). + * Create a process using posix_spawn(2). A small helper is spawned + * which cleans up the inherited file descriptors and (if required) + * changes directory to the new WD, and then spawns the real target. * * @param std_fds array of file descriptors. Indexes 0, 1, and * 2 correspond to standard input, standard output and @@ -61,12 +73,27 @@ * if and only if it is not -1 on output. * @return the pid of the subprocess */ - private native int forkAndExec(byte[] prog, + private int spawn (byte[] prog, byte[] argBlock, int argc, byte[] envBlock, int envc, byte[] dir, int[] std_fds, boolean redirectErrorStream) + throws IOException + { + return forkAndExec ( + prog, argBlock, argc, envBlock, envc, dir, std_fds, + javahome + "/bin/processhelper", redirectErrorStream + ); + } + + private native int forkAndExec (byte[] prog, + byte[] argBlock, int argc, + byte[] envBlock, int envc, + byte[] dir, + int[] std_fds, + String helper, + boolean redirectErrorStream) throws IOException; UNIXProcess(final byte[] prog, @@ -76,7 +103,7 @@ final int[] std_fds, final boolean redirectErrorStream) throws IOException { - pid = forkAndExec(prog, + pid = spawn(prog, argBlock, argc, envBlock, envc, dir,