in maven-release-manager/src/main/java/org/apache/maven/shared/release/exec/ForkedMavenExecutor.java [169:231]
public static int executeCommandLine(
Commandline cl, InputStream systemIn, OutputStream systemOut, OutputStream systemErr)
throws CommandLineException {
if (cl == null) {
throw new IllegalArgumentException("cl cannot be null.");
}
Process p = cl.execute();
// processes.put( new Long( cl.getPid() ), p );
RawStreamPumper inputFeeder = null;
if (systemIn != null) {
inputFeeder = new RawStreamPumper(systemIn, p.getOutputStream(), true);
}
RawStreamPumper outputPumper = new RawStreamPumper(p.getInputStream(), systemOut);
RawStreamPumper errorPumper = new RawStreamPumper(p.getErrorStream(), systemErr);
if (inputFeeder != null) {
inputFeeder.start();
}
outputPumper.start();
errorPumper.start();
try {
int returnValue = p.waitFor();
if (inputFeeder != null) {
inputFeeder.setDone();
}
outputPumper.setDone();
errorPumper.setDone();
// processes.remove( new Long( cl.getPid() ) );
return returnValue;
} catch (InterruptedException ex) {
// killProcess( cl.getPid() );
throw new CommandLineException("Error while executing external command, process killed.", ex);
} finally {
try {
errorPumper.closeInput();
} catch (IOException e) {
// ignore
}
try {
outputPumper.closeInput();
} catch (IOException e) {
// ignore
}
if (inputFeeder != null) {
try {
inputFeeder.closeOutput();
} catch (IOException e) {
// ignore
}
}
}
}