[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] Spawner patch
|
Fixing problem in Spaner.java: wrong processing of exception generated in
spawner.dll.
Index: Spawner.java
===================================================================
RCS file:
/home/tools/org.eclipse.cdt.core/utils/org/eclipse/cdt/utils/spawner/Spawner
.java,v
retrieving revision 1.3
diff -u -r1.3 Spawner.java
--- Spawner.java 9 Oct 2002 12:40:43 -0000 1.3
+++ Spawner.java 15 Oct 2002 21:55:02 -0000
@@ -33,16 +33,16 @@
for (int n = 0; tokenizer.hasMoreTokens(); n++)
cmdarray[n] = tokenizer.nextToken();
if (bNoRedirect)
- exec_detached(cmdarray, new String[0], ".");
+ exec_detached(cmdarray, new String[0], "."); //$NON-NLS-1$
else
- exec(cmdarray, new String[0], ".");
+ exec(cmdarray, new String[0], "."); //$NON-NLS-1$
}
/**
* Executes the specified command and arguments in a separate process with
the
* specified environment and working directory.
**/
protected Spawner(String[] cmdarray, String[] envp, File dir) throws
IOException {
- String dirpath = ".";
+ String dirpath = "."; //$NON-NLS-1$
if (dir != null)
dirpath = dir.getAbsolutePath();
exec(cmdarray, envp, dirpath);
@@ -87,7 +87,7 @@
String[] cmdarray = new String[tokenizer.countTokens()];
for (int n = 0; tokenizer.hasMoreTokens(); n++)
cmdarray[n] = tokenizer.nextToken();
- String dirpath = ".";
+ String dirpath = "."; //$NON-NLS-1$
if (dir != null)
dirpath = dir.getAbsolutePath();
exec(cmdarray, envp, dirpath);
@@ -196,7 +196,7 @@
if (envp == null)
envp = new String[0];
- Thread reaper = new Reaper(cmdarray, envp, dirpath);
+ Reaper reaper = new Reaper(cmdarray, envp, dirpath);
reaper.setDaemon(true);
reaper.start();
@@ -212,7 +212,7 @@
// Check for errors.
if (pid == -1) {
- throw new IOException("Exec error");
+ throw new IOException("Exec error:" + reaper.getErrorMessage());
}
in = new SpawnerInputStream(channels[1]);
err = new SpawnerInputStream(channels[2]);
@@ -228,18 +228,16 @@
if (envp == null)
envp = new String[0];
pid = exec1(cmdarray, envp, dirpath);
- if (pid == -1) {
- throw new IOException("Exec error");
- }
+
}
- private native int exec0( String[] cmdarray, String[] envp, String dir,
int[] chan);
- private native int exec1( String[] cmdarray, String[] envp, String dir);
+ protected native int exec0( String[] cmdarray, String[] envp, String dir,
int[] chan) throws IOException;
+ private native int exec1( String[] cmdarray, String[] envp, String dir)
throws IOException;
private native int raise(int pid, int sig);
- private native int waitFor(int pid);
+ protected native int waitFor(int pid);
static {
- System.loadLibrary("spawner");
+ System.loadLibrary("spawner"); //$NON-NLS-1$
}
// Spawn a thread to handle the forking and waiting
@@ -250,26 +248,36 @@
String[] cmdarray;
String[] envp;
String dirpath;
+ String errMsg = new String();
public Reaper(String[] array, String[] env, String dir) {
- super("Spawner Reaper");
+ super("Spawner Reaper"); //$NON-NLS-1$
cmdarray = array;
envp = env;
dirpath = dir;
}
public void run() {
- pid = exec0(cmdarray, envp, dirpath, channels);
+ try {
+ pid = exec0(cmdarray, envp, dirpath, channels);
+ } catch(IOException e) {
+ pid = -1;
+ errMsg = e.getMessage();
+ }
// Tell spawner that the process started.
synchronized (Spawner.this) {
Spawner.this.notifyAll();
}
// Sync with spawner and notify when done.
- status = waitFor(pid);
+ status = waitFor(pid); //$NON-NLS-1$
synchronized (Spawner.this) {
isDone = true;
Spawner.this.notifyAll();
}
+ }
+
+ public String getErrorMessage() {
+ return errMsg;
}
}
}