} catch (JIException e) {
throw new IOException2(e);
} catch (InterruptedException e) {
throw new IOException2(e);
}
final Thread t1 = new StreamCopyThread("stdout copier: "+name, proc.getInputStream(), ps.stdout(),false);
t1.start();
final Thread t2 = new StreamCopyThread("stdin copier: "+name,ps.stdin(), proc.getOutputStream(),true);
t2.start();
return new Proc() {
public boolean isAlive() throws IOException, InterruptedException {
try {
proc.exitValue();
return false;
} catch (IllegalThreadStateException e) {
return true;
}
}
public void kill() throws IOException, InterruptedException {
t1.interrupt();
t2.interrupt();
proc.destroy();
}
public int join() throws IOException, InterruptedException {
try {
t1.join();
t2.join();
return proc.waitFor();
} finally {
proc.destroy();
}
}