Class ProcessHelpers
- java.lang.Object
-
- org.kiwiproject.beta.base.process.ProcessHelpers
-
@Beta public final class ProcessHelpers extends Object
Utilities to execute a command using aProcessHelper.These static methods could be considered for addition to kiwi's
ProcessHelper. They would be instance methods inside ProcessHelper. Static versions of the methods could also be added to kiwi's Processes class (which contains only static utilities), and then the instance methods in ProcessHelper would delegate, thereby providing two ways to use this. Using ProcessHelper is more friendly to testing since it can easily be mocked.
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ProcessResultexecute(org.kiwiproject.base.process.ProcessHelper processHelper, List<String> command)Execute command with timeout of 5 seconds.static ProcessResultexecute(org.kiwiproject.base.process.ProcessHelper processHelper, List<String> command, int timeout, TimeUnit timeoutUnit)Execute command with the given timeout.
-
-
-
Method Detail
-
execute
public static ProcessResult execute(org.kiwiproject.base.process.ProcessHelper processHelper, List<String> command)
Execute command with timeout of 5 seconds.- Implementation Note:
- See the implementation note in
execute(ProcessHelper, List, int, TimeUnit).
-
execute
public static ProcessResult execute(org.kiwiproject.base.process.ProcessHelper processHelper, List<String> command, int timeout, TimeUnit timeoutUnit)
Execute command with the given timeout.- Implementation Note:
- This uses
CompletableFutureto ensure we time out even if the stdout or stderr blocks, which according to theProcessdocs, can at least theoretically happen. For example, if someone gives the commandls -laR /to list all files in the filesystem, it will probably take quite a long time.
-
-