Class ProcessProperties
java.lang.Object
org.graalvm.nativeimage.ProcessProperties
Utility class to get and set properties of the OS process at run time.
- Since:
- 19.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic booleandestroy(long processID) Kills the process.static booleandestroyForcibly(long processID) Kills the process forcibly.static voidReplaces the current process image with the process image specified by the given path invoked with the given args.static voidReplaces the current process image with the process image specified by the given path invoked with the given arguments and environment.static intIf the running image is an executable the total size of the argument vector of the running process gets returned.static StringIf the running image is an executable the program name that is stored in the argument vector of the running process gets returned.static StringReturn the canonicalized absolute pathname of the executable.static StringgetObjectFile(String symbol) Return the path of the object file defining the symbol specified as aStringcontaining the symbol name.static StringgetObjectFile(CEntryPointLiteral<?> symbol) Return the path of the object file defining the symbol specified as aCEntryPointLiteralcontaining a function pointer to symbol.static longGet the Process ID of the process executing the image.static longgetProcessID(Process process) Get the Process ID of the given process object.static booleanisAlive(long processID) Tests whether the process represented by the given Process ID is alive.static booleanIf the running image is an executable the program name that is stored in the argument vector of the running process gets replaced with the given name.static StringDeprecated.in 25.0 without replacement.static intwaitForProcessExit(long processID) Wait for process termination and return its exit status.
-
Method Details
-
getExecutableName
Return the canonicalized absolute pathname of the executable.- Since:
- 19.0
-
getProcessID
public static long getProcessID()Get the Process ID of the process executing the image.- Since:
- 19.0
-
getProcessID
Get the Process ID of the given process object.- Since:
- 19.0
-
waitForProcessExit
public static int waitForProcessExit(long processID) Wait for process termination and return its exit status.- Since:
- 19.0
-
destroy
public static boolean destroy(long processID) Kills the process. Whether the process represented by the given Process ID is normally terminated or not is implementation dependent.- Since:
- 19.0
-
destroyForcibly
public static boolean destroyForcibly(long processID) Kills the process forcibly. The process represented by the given Process ID is forcibly terminated. Forcible process destruction is defined as the immediate termination of a process, whereas normal termination allows the process to shut down cleanly.- Since:
- 19.0
-
isAlive
public static boolean isAlive(long processID) Tests whether the process represented by the given Process ID is alive.- Returns:
- true if the process represented by the given Process ID object has not yet terminated.
- Since:
- 19.0
-
getObjectFile
-
getObjectFile
Return the path of the object file defining the symbol specified as aCEntryPointLiteralcontaining a function pointer to symbol.- Since:
- 19.0
-
setLocale
Deprecated.in 25.0 without replacement. This method is inherently unsafe becausesetlocale(...)is not thread-safe on the OS level.Set the program locale.- Since:
- 19.0
-
exec
-
exec
Replaces the current process image with the process image specified by the given path invoked with the given arguments and environment. If the process should inherit members of the calling environment, those members need to be added by the caller. This method does not return if the call is successful.- Since:
- 22.1
-
getArgumentVectorProgramName
If the running image is an executable the program name that is stored in the argument vector of the running process gets returned.- Throws:
UnsupportedOperationException- if called from a platform that does not support argument vector manipulation (Windows) or if called from a shared library image.- Since:
- 20.1
-
setArgumentVectorProgramName
If the running image is an executable the program name that is stored in the argument vector of the running process gets replaced with the given name. If the size of the argument vector is too small for the given name it gets truncated so that the environment vector next to the argument vector does not get corrupted.- Returns:
- true, if given name had to be truncated to fit in the argument vector
- Throws:
UnsupportedOperationException- if called from a platform that does not support argument vector manipulation (Windows) or if called from a shared library image.- Since:
- 20.1
-
getArgumentVectorBlockSize
public static int getArgumentVectorBlockSize()If the running image is an executable the total size of the argument vector of the running process gets returned.- Returns:
- the total size of the argument vector. Returns -1 if not supported on platform or called from a shared library image.
- Since:
- 20.1
-