java.lang.Object
org.itsallcode.process.SimpleProcess<T>
- Type Parameters:
T- type of stdout and stderr, e.g.String.
Provides control over native processes.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Kill the process.voidKill the process forcibly.intGet the exit value of the process.Get the standard error of the process.Get the standard output of the process.booleanisAlive()Check wether the process is alive.longpid()Get the process ID.voidWait until the process terminates successfully with exit code0.intWait until the process has terminated.voidwaitForTermination(int expectedExitCode) Wait until the process terminates successfully with the given exit code.voidwaitForTermination(Duration timeout) Wait until the process terminates with the given timeout.
-
Method Details
-
waitForTermination
Wait until the process has terminated.- Returns:
- exit code
- See Also:
-
waitForSuccessfulTermination
Wait until the process terminates successfully with exit code0.- Throws:
IllegalStateException- if exit code is not equal to0.- See Also:
-
waitForTermination
Wait until the process terminates successfully with the given exit code.- Parameters:
expectedExitCode- expected exit code- Throws:
IllegalStateException- if exit code is not equal to the given expected exit code.- See Also:
-
waitForTermination
Wait until the process terminates with the given timeout.- Parameters:
timeout- maximum time to wait for the termination- Throws:
IllegalStateException- if process does not exit within the given timeout.- See Also:
-
getStdOut
Get the standard output of the process.- Returns:
- standard output
-
getStdErr
Get the standard error of the process.- Returns:
- standard error
-
isAlive
Check wether the process is alive.- Returns:
trueif the process has not yet terminated- See Also:
-
exitValue
Get the exit value of the process.- Returns:
- exit value
- See Also:
-
pid
Get the process ID.- Returns:
- process ID
- See Also:
-
destroy
Kill the process.- See Also:
-
destroyForcibly
Kill the process forcibly.- See Also:
-