Interface ProcessWrapper
-
- All Known Implementing Classes:
ProcessWrapperImpl
@ScannerSide @SonarLintSide(lifespan="MULTIPLE_ANALYSES") public interface ProcessWrapper
This interface provides thin wrapper around Java ProcessBuilder and related APIs. The goal is to make them testable across different OS flavors. It also handles the issue of consuming stdout and stderr of started process in an asynchronous way using a daemon thread
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
destroyForcibly(Process process)
int
exitValue(Process process)
String
getenv(String name)
void
interrupt()
boolean
isMac()
boolean
isWindows()
Process
startProcess(List<String> commandLine, Map<String,String> env, Consumer<String> outputConsumer, Consumer<String> errorConsumer)
boolean
waitFor(Process process, long timeout, TimeUnit unit)
-
-
-
Method Detail
-
startProcess
Process startProcess(List<String> commandLine, Map<String,String> env, Consumer<String> outputConsumer, Consumer<String> errorConsumer) throws IOException
- Throws:
IOException
-
waitFor
boolean waitFor(Process process, long timeout, TimeUnit unit) throws InterruptedException
- Throws:
InterruptedException
-
interrupt
void interrupt()
-
destroyForcibly
void destroyForcibly(Process process)
-
isMac
boolean isMac()
-
isWindows
boolean isWindows()
-
exitValue
int exitValue(Process process)
-
-