diff options
Diffstat (limited to 'libjava')
-rw-r--r-- | libjava/ChangeLog | 18 | ||||
-rw-r--r-- | libjava/java/lang/EcosProcess.java | 6 | ||||
-rw-r--r-- | libjava/java/lang/PosixProcess.java | 12 | ||||
-rw-r--r-- | libjava/java/lang/Runtime.java | 10 | ||||
-rw-r--r-- | libjava/java/lang/Win32Process.java | 6 | ||||
-rw-r--r-- | libjava/java/lang/natPosixProcess.cc | 19 | ||||
-rw-r--r-- | libjava/java/lang/natRuntime.cc | 6 |
7 files changed, 60 insertions, 17 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog index 8c4208b..e279ce9 100644 --- a/libjava/ChangeLog +++ b/libjava/ChangeLog @@ -1,3 +1,21 @@ +2002-08-13 Jesse Rosenstock <jmr@ugcs.caltech.edu> + + Fix for PR libgcj/7570 and PR libgcj/7578: + * java/lang/natPosixProcess.cc: Include java/io/File.h. + (startProcess): Handle new `dir' argument. + * java/lang/Win32Process.java (ConcreteProcess): Added `dir' + argument. + * java/lang/PosixProcess.java (ConcreteProcess): Added `dir' + argument. + (startProcess): Likewise. + * java/lang/EcosProcess.java (ConcreteProcess): Added `dir' + argument. + * java/lang/Runtime.java (execInternal): Added `dir' argument. + (exec): Don't create new environment if ENV==null. Pass DIR to + execInternal. + * java/lang/natRuntime.cc: Include java/io/File.h. + (execInternal): Added `dir' argument. + 2002-08-13 Jesse Rosenstock <jmr@fulcrummicro.com> * java/io/RandomAccessFile.java (skipBytes): Return number of diff --git a/libjava/java/lang/EcosProcess.java b/libjava/java/lang/EcosProcess.java index 4c200a0..aff534a 100644 --- a/libjava/java/lang/EcosProcess.java +++ b/libjava/java/lang/EcosProcess.java @@ -10,6 +10,7 @@ details. */ package java.lang; +import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; @@ -52,7 +53,10 @@ final class ConcreteProcess extends Process return 0; } - public ConcreteProcess (String[] progarray, String[] envp) throws IOException + public ConcreteProcess (String[] progarray, + String[] envp, + File dir) + throws IOException { throw new IOException ("eCos processes unimplemented"); } diff --git a/libjava/java/lang/PosixProcess.java b/libjava/java/lang/PosixProcess.java index 459f76c..199391b 100644 --- a/libjava/java/lang/PosixProcess.java +++ b/libjava/java/lang/PosixProcess.java @@ -10,6 +10,7 @@ details. */ package java.lang; +import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; @@ -53,15 +54,20 @@ final class ConcreteProcess extends Process // This is used for actual initialization, as we can't write a // native constructor. - public native void startProcess (String[] progarray, String[] envp) + public native void startProcess (String[] progarray, + String[] envp, + File dir) throws IOException; // This file is copied to `ConcreteProcess.java' before // compilation. Hence the constructor name apparently does not // match the file name. - public ConcreteProcess (String[] progarray, String[] envp) throws IOException + public ConcreteProcess (String[] progarray, + String[] envp, + File dir) + throws IOException { - startProcess (progarray, envp); + startProcess (progarray, envp, dir); } // The process id. This is cast to a pid_t on the native side. diff --git a/libjava/java/lang/Runtime.java b/libjava/java/lang/Runtime.java index eb34391..932600b 100644 --- a/libjava/java/lang/Runtime.java +++ b/libjava/java/lang/Runtime.java @@ -526,7 +526,6 @@ public class Runtime * entries * @throws IndexOutOfBoundsException if cmd is length 0 * @since 1.3 - * @XXX Ignores dir, for now */ public Process exec(String[] cmd, String[] env, File dir) throws IOException @@ -534,10 +533,7 @@ public class Runtime SecurityManager sm = securityManager; // Be thread-safe! if (sm != null) sm.checkExec(cmd[0]); - if (env == null) - env = new String[0]; - //XXX Should be: return execInternal(cmd, env, dir); - return execInternal(cmd, env); + return execInternal(cmd, env, dir); } /** @@ -729,7 +725,6 @@ public class Runtime * the environment should contain name=value mappings. If directory is null, * use the current working directory; otherwise start the process in that * directory. - * XXX Add directory support. * * @param cmd the non-null command tokens * @param env the non-null environment setup @@ -737,8 +732,7 @@ public class Runtime * @return the newly created process * @throws NullPointerException if cmd or env have null elements */ - // native Process execInternal(String[] cmd, String[] env, File dir); - native Process execInternal(String[] cmd, String[] env); + native Process execInternal(String[] cmd, String[] env, File dir); /** * Get the system properties. This is done here, instead of in System, diff --git a/libjava/java/lang/Win32Process.java b/libjava/java/lang/Win32Process.java index 0af2457..72911d2 100644 --- a/libjava/java/lang/Win32Process.java +++ b/libjava/java/lang/Win32Process.java @@ -10,6 +10,7 @@ details. */ package java.lang; +import java.io.File; import java.io.InputStream; import java.io.OutputStream; import java.io.IOException; @@ -60,7 +61,10 @@ final class ConcreteProcess extends Process throw new Error("not implemented"); } - public ConcreteProcess (String[] progarray, String[] envp) throws IOException + public ConcreteProcess (String[] progarray, + String[] envp, + File dir) + throws IOException { throw new IOException("not implemented"); } diff --git a/libjava/java/lang/natPosixProcess.cc b/libjava/java/lang/natPosixProcess.cc index b480afb..a6c049b 100644 --- a/libjava/java/lang/natPosixProcess.cc +++ b/libjava/java/lang/natPosixProcess.cc @@ -30,6 +30,7 @@ details. */ #include <java/lang/InterruptedException.h> #include <java/lang/NullPointerException.h> #include <java/lang/Thread.h> +#include <java/io/File.h> #include <java/io/FileDescriptor.h> #include <java/io/FileInputStream.h> #include <java/io/FileOutputStream.h> @@ -116,7 +117,8 @@ myclose (int &fd) void java::lang::ConcreteProcess::startProcess (jstringArray progarray, - jstringArray envp) + jstringArray envp, + java::io::File *dir) { using namespace java::io; @@ -188,7 +190,7 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray, if (pid == 0) { - // Child process, so remap descriptors and exec. + // Child process, so remap descriptors, chdir and exec. if (envp) { @@ -229,6 +231,19 @@ java::lang::ConcreteProcess::startProcess (jstringArray progarray, close (outp[0]); close (outp[1]); close (msgp[0]); + + // Change directory. + if (dir != NULL) + { + // We don't care about leaking memory here; this process + // is about to terminate one way or another. + if (chdir (new_string (dir->getPath ())) != 0) + { + char c = errno; + write (msgp[1], &c, 1); + _exit (127); + } + } execvp (args[0], args); diff --git a/libjava/java/lang/natRuntime.cc b/libjava/java/lang/natRuntime.cc index acd44f1..18ec232 100644 --- a/libjava/java/lang/natRuntime.cc +++ b/libjava/java/lang/natRuntime.cc @@ -21,6 +21,7 @@ details. */ #include <java/lang/UnsatisfiedLinkError.h> #include <gnu/gcj/runtime/FileDeleter.h> #include <gnu/gcj/runtime/FinalizerThread.h> +#include <java/io/File.h> #include <java/util/Properties.h> #include <java/util/TimeZone.h> #include <java/lang/StringBuffer.h> @@ -538,9 +539,10 @@ java::lang::Runtime::insertSystemProperties (java::util::Properties *newprops) java::lang::Process * java::lang::Runtime::execInternal (jstringArray cmd, - jstringArray env) + jstringArray env, + java::io::File *dir) { - return new java::lang::ConcreteProcess (cmd, env); + return new java::lang::ConcreteProcess (cmd, env, dir); } jint |