Class ProcessProperties

java.lang.Object
org.graalvm.nativeimage.ProcessProperties

public final class ProcessProperties extends Object
Utility class to get and set properties of the OS process at run time.
Since:
19.0
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    destroy(long processID)
    Kills the process.
    static boolean
    destroyForcibly(long processID)
    Kills the process forcibly.
    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.
    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.
    static int
    If the running image is an executable the total size of the argument vector of the running process gets returned.
    static String
    If the running image is an executable the program name that is stored in the argument vector of the running process gets returned.
    static String
    Return the canonicalized absolute pathname of the executable.
    static String
    Return the path of the object file defining the symbol specified as a String containing the symbol name.
    static String
    Return the path of the object file defining the symbol specified as a CEntryPointLiteral containing a function pointer to symbol.
    static long
    Get the Process ID of the process executing the image.
    static long
    Get the Process ID of the given process object.
    static boolean
    isAlive(long processID)
    Tests whether the process represented by the given Process ID is alive.
    static boolean
    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.
    static String
    setLocale(String category, String locale)
    Set the program locale.
    static int
    waitForProcessExit(long processID)
    Wait for process termination and return its exit status.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getExecutableName

      public static String 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

      public static long getProcessID(Process process)
      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

      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
    • getObjectFile

      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
    • setLocale

      public static String setLocale(String category, String locale)
      Set the program locale.
      Since:
      19.0
    • exec

      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
    • exec

      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
    • getArgumentVectorProgramName

      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.
      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

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