mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 17:56:01 +02:00
Add $NON-NLS-1$ when necessary.
native methods should throw Exceptions.
This commit is contained in:
parent
df56cb6372
commit
e38c670d27
1 changed files with 33 additions and 18 deletions
|
@ -33,16 +33,16 @@ public class Spawner extends Process {
|
||||||
for (int n = 0; tokenizer.hasMoreTokens(); n++)
|
for (int n = 0; tokenizer.hasMoreTokens(); n++)
|
||||||
cmdarray[n] = tokenizer.nextToken();
|
cmdarray[n] = tokenizer.nextToken();
|
||||||
if (bNoRedirect)
|
if (bNoRedirect)
|
||||||
exec_detached(cmdarray, new String[0], ".");
|
exec_detached(cmdarray, new String[0], "."); //$NON-NLS-1$
|
||||||
else
|
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
|
* Executes the specified command and arguments in a separate process with the
|
||||||
* specified environment and working directory.
|
* specified environment and working directory.
|
||||||
**/
|
**/
|
||||||
protected Spawner(String[] cmdarray, String[] envp, File dir) throws IOException {
|
protected Spawner(String[] cmdarray, String[] envp, File dir) throws IOException {
|
||||||
String dirpath = ".";
|
String dirpath = "."; //$NON-NLS-1$
|
||||||
if (dir != null)
|
if (dir != null)
|
||||||
dirpath = dir.getAbsolutePath();
|
dirpath = dir.getAbsolutePath();
|
||||||
exec(cmdarray, envp, dirpath);
|
exec(cmdarray, envp, dirpath);
|
||||||
|
@ -87,7 +87,7 @@ public class Spawner extends Process {
|
||||||
String[] cmdarray = new String[tokenizer.countTokens()];
|
String[] cmdarray = new String[tokenizer.countTokens()];
|
||||||
for (int n = 0; tokenizer.hasMoreTokens(); n++)
|
for (int n = 0; tokenizer.hasMoreTokens(); n++)
|
||||||
cmdarray[n] = tokenizer.nextToken();
|
cmdarray[n] = tokenizer.nextToken();
|
||||||
String dirpath = ".";
|
String dirpath = "."; //$NON-NLS-1$
|
||||||
if (dir != null)
|
if (dir != null)
|
||||||
dirpath = dir.getAbsolutePath();
|
dirpath = dir.getAbsolutePath();
|
||||||
exec(cmdarray, envp, dirpath);
|
exec(cmdarray, envp, dirpath);
|
||||||
|
@ -135,7 +135,7 @@ public class Spawner extends Process {
|
||||||
**/
|
**/
|
||||||
public synchronized int exitValue() {
|
public synchronized int exitValue() {
|
||||||
if (!isDone) {
|
if (!isDone) {
|
||||||
throw new IllegalThreadStateException("Process not Terminated");
|
throw new IllegalThreadStateException("Process not Terminated"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -196,7 +196,7 @@ public class Spawner extends Process {
|
||||||
if (envp == null)
|
if (envp == null)
|
||||||
envp = new String[0];
|
envp = new String[0];
|
||||||
|
|
||||||
Thread reaper = new Reaper(cmdarray, envp, dirpath);
|
Reaper reaper = new Reaper(cmdarray, envp, dirpath);
|
||||||
reaper.setDaemon(true);
|
reaper.setDaemon(true);
|
||||||
reaper.start();
|
reaper.start();
|
||||||
|
|
||||||
|
@ -212,7 +212,7 @@ public class Spawner extends Process {
|
||||||
|
|
||||||
// Check for errors.
|
// Check for errors.
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
throw new IOException("Exec error");
|
throw new IOException("Exec error:" + reaper.getErrorMessage()); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
in = new SpawnerInputStream(channels[1]);
|
in = new SpawnerInputStream(channels[1]);
|
||||||
err = new SpawnerInputStream(channels[2]);
|
err = new SpawnerInputStream(channels[2]);
|
||||||
|
@ -229,17 +229,17 @@ public class Spawner extends Process {
|
||||||
envp = new String[0];
|
envp = new String[0];
|
||||||
pid = exec1(cmdarray, envp, dirpath);
|
pid = exec1(cmdarray, envp, dirpath);
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
throw new IOException("Exec error");
|
throw new IOException("Exec error"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
native int exec0( String[] cmdarray, String[] envp, String dir, int[] chan);
|
native int exec0( String[] cmdarray, String[] envp, String dir, int[] chan) throws IOException;
|
||||||
native int exec1( String[] cmdarray, String[] envp, String dir);
|
native int exec1( String[] cmdarray, String[] envp, String dir) throws IOException;
|
||||||
native int raise(int pid, int sig);
|
native int raise(int pid, int sig);
|
||||||
native int waitFor(int pid);
|
native int waitFor(int pid);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
System.loadLibrary("spawner");
|
System.loadLibrary("spawner"); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
// Spawn a thread to handle the forking and waiting
|
// Spawn a thread to handle the forking and waiting
|
||||||
|
@ -250,26 +250,41 @@ public class Spawner extends Process {
|
||||||
String[] cmdarray;
|
String[] cmdarray;
|
||||||
String[] envp;
|
String[] envp;
|
||||||
String dirpath;
|
String dirpath;
|
||||||
|
String errMesg;
|
||||||
|
|
||||||
public Reaper(String[] array, String[] env, String dir) {
|
public Reaper(String[] array, String[] env, String dir) {
|
||||||
super("Spawner Reaper");
|
super("Spawner Reaper"); //$NON-NLS-1$
|
||||||
cmdarray = array;
|
cmdarray = array;
|
||||||
envp = env;
|
envp = env;
|
||||||
dirpath = dir;
|
dirpath = dir;
|
||||||
|
errMesg = new String();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void run() {
|
public void run() {
|
||||||
pid = exec0(cmdarray, envp, dirpath, channels);
|
try {
|
||||||
|
pid = exec0(cmdarray, envp, dirpath, channels);
|
||||||
|
} catch (IOException e) {
|
||||||
|
pid = -1;
|
||||||
|
errMesg = e.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
// Tell spawner that the process started.
|
// Tell spawner that the process started.
|
||||||
synchronized (Spawner.this) {
|
synchronized (Spawner.this) {
|
||||||
Spawner.this.notifyAll();
|
Spawner.this.notifyAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync with spawner and notify when done.
|
if (pid != -1) {
|
||||||
status = waitFor(pid);
|
// Sync with spawner and notify when done.
|
||||||
synchronized (Spawner.this) {
|
status = waitFor(pid);
|
||||||
isDone = true;
|
synchronized (Spawner.this) {
|
||||||
Spawner.this.notifyAll();
|
isDone = true;
|
||||||
|
Spawner.this.notifyAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getErrorMessage() {
|
||||||
|
return errMesg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue