Top Description Constructors Methods
org.graalvm.nativeimage

public final Class ProcessProperties

extends Object
Class Inheritance
Imports
java.nio.file.Path, java.util.Map, org.graalvm.nativeimage.c.function.CEntryPointLiteral, org.graalvm.nativeimage.impl.ProcessPropertiesSupport

Utility class to get and set properties of the OS process at run time.
Since
19.0

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static boolean
destroy(long processID)

Kills the process.

public static boolean
destroyForcibly(long processID)

Kills the process forcibly.

public static void
exec(Path executable, String... args)

Replaces the current process image with the process image specified by the given path invoked with the given args.

public static void
exec(Path executable, String[] args, Map<String, String> env)

Replaces the current process image with the process image specified by the given path invoked with the given arguments and environment.

public static int

Returns:

the total size of the argument vector. Returns -1 if not supported on platform or called from a shared library image.
getArgumentVectorBlockSize
()

If the running image is an executable the total size of the argument vector of the running process gets returned.

public static String
getArgumentVectorProgramName()

If the running image is an executable the program name that is stored in the argument vector of the running process gets returned.

public static String
getExecutableName()

Return the canonicalized absolute pathname of the executable.

public static String
getObjectFile(String symbol)

Return the path of the object file defining the symbol specified as a String containing the symbol name.

public static String
getObjectFile(CEntryPointLiteral<?> symbol)

Return the path of the object file defining the symbol specified as a CEntryPointLiteral containing a function pointer to symbol.

public static long
getProcessID()

Get the Process ID of the process executing the image.

public static long
getProcessID(Process process)

Get the Process ID of the given process object.

public static boolean

Returns:

true if the process represented by the given Process ID object has not yet terminated.
isAlive
(long processID)

Tests whether the process represented by the given Process ID is alive.

public static boolean

Returns:

true, if given name had to be truncated to fit in the argument vector
setArgumentVectorProgramName
(String name)

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.

public static String
setLocale(String category, String locale)

Set the program locale.

public static int
waitForProcessExit(long processID)

Wait for process termination and return its exit status.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ProcessPropertiesback to summary
private ProcessProperties()

Method Detail

destroyback to summary
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
destroyForciblyback to summary
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
execback to summary
public static void exec(Path executable, String... args)

Replaces the current process image with the process image specified by the given path invoked with the given args. This method does not return if the call is successful.

Since
19.0
execback to summary
public static void exec(Path executable, String[] args, Map<String, String> env)

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
getArgumentVectorBlockSizeback to summary
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:int

the total size of the argument vector. Returns -1 if not supported on platform or called from a shared library image.

Since
20.1
getArgumentVectorProgramNameback to summary
public static String getArgumentVectorProgramName()

If the running image is an executable the program name that is stored in the argument vector of the running process gets returned.

Exceptions
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
getExecutableNameback to summary
public static String getExecutableName()

Return the canonicalized absolute pathname of the executable.

Since
19.0
getObjectFileback to summary
public static String getObjectFile(String symbol)

Return the path of the object file defining the symbol specified as a String containing the symbol name.

Since
19.0
getObjectFileback to summary
public static String getObjectFile(CEntryPointLiteral<?> symbol)

Return the path of the object file defining the symbol specified as a CEntryPointLiteral containing a function pointer to symbol.

Since
19.0
getProcessIDback to summary
public static long getProcessID()

Get the Process ID of the process executing the image.

Since
19.0
getProcessIDback to summary
public static long getProcessID(Process process)

Get the Process ID of the given process object.

Since
19.0
isAliveback to summary
public static boolean isAlive(long processID)

Tests whether the process represented by the given Process ID is alive.

Returns:boolean

true if the process represented by the given Process ID object has not yet terminated.

Since
19.0
setArgumentVectorProgramNameback to summary
public static boolean setArgumentVectorProgramName(String name)

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:boolean

true, if given name had to be truncated to fit in the argument vector

Exceptions
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
setLocaleback to summary
public static String setLocale(String category, String locale)

Set the program locale.

Since
19.0
waitForProcessExitback to summary
public static int waitForProcessExit(long processID)

Wait for process termination and return its exit status.

Since
19.0