Class ProcessUtils


  • public class ProcessUtils
    extends java.lang.Object
    • Constructor Summary

      Constructors 
      Constructor Description
      ProcessUtils()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static int getPid​(int fallback)
      Tries to get the PID of the current process caching it for future calls since it won't change throughout the life of the process
      static boolean isAlive​(int pid)
      Determines whether a given PID is alive
      static boolean negativePidsTreatedAsAlive()
      Gets whether the platform we are running on will cause us to treat negative (i.e.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ProcessUtils

        public ProcessUtils()
    • Method Detail

      • getPid

        public static int getPid​(int fallback)
        Tries to get the PID of the current process caching it for future calls since it won't change throughout the life of the process
        Parameters:
        fallback - Fallback PID to return if unable to determine the PID i.e. an error code to return
        Returns:
        PID of current process or provided fallback if unable to determine PID
      • isAlive

        public static boolean isAlive​(int pid)
        Determines whether a given PID is alive
        Parameters:
        pid - PID
        Returns:
        True if the given PID is alive or unknown, false if it is dead
      • negativePidsTreatedAsAlive

        public static boolean negativePidsTreatedAsAlive()
        Gets whether the platform we are running on will cause us to treat negative (i.e. invalid) PIDs as alive because of the format in which the command line process monitor application for the system returns errors for invalid PIDs
        Returns:
        True if a negative PID is treated as alive on this platform or we cannot determine liveness for PIDs on this platform, false otherwise