public class CommandlineExecutor extends Object implements Closeable
try ( CommandlineExecutor exec = new CommandlineExecutor( cli, endOfStreamsCountdown );
CommandlineStreams streams = exec.execute() )
{
// register exec in the shutdown hook to destroy pending process
// register streams in the shutdown hook to close all three streams
ReadableByteChannel stdOut = streams.getStdOutChannel();
ReadableByteChannel stdErr = streams.getStdErrChannel();
WritableByteChannel stdIn = streams.getStdInChannel();
// lineConsumerThread = new LineConsumerThread( ..., stdErr, ..., endOfStreamsCountdown );
// lineConsumerThread.start();
// stdIn.write( ... );
int exitCode = exec.awaitExit();
// process exitCode
}
catch ( InterruptedException e )
{
lineConsumerThread.disable();
}
catch ( CommandLineException e )
{
// handle the exceptions
}
Constructor and Description |
---|
CommandlineExecutor(org.apache.maven.surefire.shared.utils.cli.Commandline cli,
CountdownCloseable endOfStreamsCountdown) |
public CommandlineExecutor(org.apache.maven.surefire.shared.utils.cli.Commandline cli, CountdownCloseable endOfStreamsCountdown)
public CommandlineStreams execute() throws org.apache.maven.surefire.shared.utils.cli.CommandLineException
org.apache.maven.surefire.shared.utils.cli.CommandLineException
public int awaitExit() throws InterruptedException
InterruptedException
public void close()
close
in interface Closeable
close
in interface AutoCloseable
Copyright © 2004–2024 The Apache Software Foundation. All rights reserved.