Package htsjdk.samtools.util
Class ProcessExecutor
java.lang.Object
htsjdk.samtools.util.ProcessExecutor
Utility class that will execute sub processes via Runtime.getRuntime().exec(...) and read
off the output from stderr and stdout of the sub process. This implementation uses a different
thread to read each stream: the current thread for stdout and another, internal thread for
stderr. This utility is able to handle concurrent executions, spawning as many threads as
are required to handle the concurrent load.
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
Executes the command via Runtime.getRuntime().exec() then writes stderr to log.error and stdout to log.info and blocks until the command is complete.static int
Executes the command via Runtime.getRuntime().exec() then writes stderr to log.error and stdout to log.info and blocks until the command is complete.static int
Executes the command via Runtime.getRuntime().exec(), writesoutputStreamString
to the process output stream if it is not null, then writes stderr to log.error and stdout to log.info and blocks until the command is complete.executeAndReturnInterleavedOutput
(String command) Execute the command and capture stdout and stderr.executeAndReturnInterleavedOutput
(String[] commandArray) Execute the command and capture stdout and stderr.static String
executeAndReturnResult
(String command)
-
Constructor Details
-
ProcessExecutor
public ProcessExecutor()
-
-
Method Details
-
execute
Executes the command via Runtime.getRuntime().exec() then writes stderr to log.error and stdout to log.info and blocks until the command is complete.- Parameters:
command
- command string- Returns:
- return code of command
- See Also:
-
execute
Executes the command via Runtime.getRuntime().exec() then writes stderr to log.error and stdout to log.info and blocks until the command is complete.- Parameters:
commandParts
- command string- Returns:
- return code of command
- See Also:
-
execute
Executes the command via Runtime.getRuntime().exec(), writesoutputStreamString
to the process output stream if it is not null, then writes stderr to log.error and stdout to log.info and blocks until the command is complete.- Parameters:
commandParts
- command string- Returns:
- return code of command
- See Also:
-
executeAndReturnResult
-
executeAndReturnInterleavedOutput
Execute the command and capture stdout and stderr.- Returns:
- Exit status of command, and both stderr and stdout interleaved into stdout attribute.
-
executeAndReturnInterleavedOutput
public static ProcessExecutor.ExitStatusAndOutput executeAndReturnInterleavedOutput(String[] commandArray) Execute the command and capture stdout and stderr.- Returns:
- Exit status of command, and both stderr and stdout interleaved into stdout attribute.
-