java.lang.Object
io.smallrye.common.process.ProcessUtil
A collection of useful process-related utility methods.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voiddestroyAllForcibly(Process process) Forcibly destroy the process and all of its descendants.static voiddestroyAllForcibly(ProcessHandle handle) Forcibly destroy the process and all of its descendants.javaHome()Returns the path corresponding tojava.homeor theJAVA_HOMEenvironment variable, if any.static StringReturns the name of the standard Java executable on this OS (notnull).static CharsetReturns the native character set (notnull).pathOfCommand(Path path) Get the absolute path of a command at the given path.static PathReturns thePathof the current Java executable (notnull).static booleanstillRunningAfter(ProcessHandle proc, long nanos) Wait (uninterruptibly) for some amount of time for the given process to finish.static booleanstillRunningAfter(Process proc, long nanos) Wait (uninterruptibly) for some amount of time for the given process to finish.static booleanstillRunningAfter(Process proc, Duration time) Wait (uninterruptibly) for some amount of time for the given process to finish.
-
Method Details
-
nativeCharset
Returns the native character set (notnull).- Returns:
- the native character set (not
null)
-
destroyAllForcibly
Forcibly destroy the process and all of its descendants.- Parameters:
handle- the root-most process handle
-
destroyAllForcibly
Forcibly destroy the process and all of its descendants.- Parameters:
process- the root-most process
-
pathOfCommand
Get the absolute path of a command at the given path. If the path is relative, then the location of the executable is determined in a platform-specific manner (typically by reading thePATHenvironment variable). If the path is absolute, it is returned if the target file is executable.- Parameters:
path- the command to locate (must not benull)- Returns:
- the optional path of the executable, or the empty optional if there is no such path (not
null)
-
searchPath
- Returns:
- the system search path (i.e. the
PATHenvironment variable) as a list ofPath(notnull)
-
pathOfJava
Returns thePathof the current Java executable (notnull). The returned path may be absolute, or it may be relative to the currentPATHof this process. If the path cannot be determined, a relative path containingnameOfJava()is returned.- Returns:
- the
Pathof the current Java executable (notnull)
-
javaHome
Returns the path corresponding tojava.homeor theJAVA_HOMEenvironment variable, if any.- Returns:
- the path corresponding to
java.homeor theJAVA_HOMEenvironment variable, if any
-
nameOfJava
Returns the name of the standard Java executable on this OS (notnull).- Returns:
- the name of the standard Java executable on this OS (not
null)
-
stillRunningAfter
Wait (uninterruptibly) for some amount of time for the given process to finish.- Parameters:
proc- the process (must not benull)nanos- the number of nanoseconds to wait- Returns:
trueif the process is still running after the elapsed time, orfalseif it has exited
-
stillRunningAfter
Wait (uninterruptibly) for some amount of time for the given process to finish.- Parameters:
proc- the process (must not benull)time- the amount of time to wait (must not benull)- Returns:
trueif the process is still running after the elapsed time, orfalseif it has exited
-
stillRunningAfter
Wait (uninterruptibly) for some amount of time for the given process to finish.- Parameters:
proc- the process handle (must not benull)nanos- the number of nanoseconds to wait- Returns:
trueif the process is still running after the elapsed time, orfalseif it has exited
-