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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@56268
138bc75d-0d04-0410-961f-
82ee72b054a4
+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
package java.lang;
+import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
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");
}
package java.lang;
+import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
// 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.
* 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
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);
}
/**
* 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
* @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,
package java.lang;
+import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.IOException;
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");
}
#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>
void
java::lang::ConcreteProcess::startProcess (jstringArray progarray,
- jstringArray envp)
+ jstringArray envp,
+ java::io::File *dir)
{
using namespace java::io;
if (pid == 0)
{
- // Child process, so remap descriptors and exec.
+ // Child process, so remap descriptors, chdir and exec.
if (envp)
{
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);
#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>
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