Class LinuxOSProcessJNA

All Implemented Interfaces:
OSProcess

@ThreadSafe public class LinuxOSProcessJNA extends LinuxOSProcess
JNA-based Linux OS process. Implements getrlimit and getrusage via JNA.
  • Constructor Details

  • Method Details

    • updateAttributes

      public boolean updateAttributes()
      Description copied from interface: OSProcess
      Attempts to update process attributes. Returns false if the update fails, which will occur if the process no longer exists.
      Specified by:
      updateAttributes in interface OSProcess
      Overrides:
      updateAttributes in class LinuxOSProcess
      Returns:
      true if the update was successful, false if the update failed. In addition, on a failed update the process state will be changed to OSProcess.State.INVALID.
    • getVoluntaryContextSwitches

      public long getVoluntaryContextSwitches()
      Description copied from interface: OSProcess
      The number of voluntary context switches the process has made. A voluntary context switch occurs when a process gives up the CPU before its time slice expires (e.g., waiting for I/O).

      For the current process, getrusage(RUSAGE_SELF) is used on supported POSIX platforms, which aggregates across all threads. For other processes, platform-specific sources are used (/proc/[pid]/status on Linux, ps on FreeBSD/OpenBSD, /proc/[pid]/usage on Solaris). On macOS, the split is only available for the current process; for other processes this returns 0.

      Specified by:
      getVoluntaryContextSwitches in interface OSProcess
      Overrides:
      getVoluntaryContextSwitches in class LinuxOSProcess
      Returns:
      voluntary context switches if available, 0 otherwise.
    • getInvoluntaryContextSwitches

      public long getInvoluntaryContextSwitches()
      Description copied from interface: OSProcess
      The number of involuntary context switches the process has made. An involuntary context switch occurs when the scheduler preempts the process (e.g., time slice expired).

      For the current process, getrusage(RUSAGE_SELF) is used on supported POSIX platforms, which aggregates across all threads. For other processes, platform-specific sources are used (/proc/[pid]/status on Linux, ps on FreeBSD/OpenBSD, /proc/[pid]/usage on Solaris). On macOS, the split is only available for the current process; for other processes this returns 0.

      Specified by:
      getInvoluntaryContextSwitches in interface OSProcess
      Overrides:
      getInvoluntaryContextSwitches in class LinuxOSProcess
      Returns:
      involuntary context switches if available, 0 otherwise.
    • queryRlimitSoft

      protected long queryRlimitSoft()
      Description copied from class: LinuxOSProcess
      Queries the soft open file limit for the current process via native getrlimit.
      Specified by:
      queryRlimitSoft in class LinuxOSProcess
      Returns:
      the soft limit value
    • queryRlimitHard

      protected long queryRlimitHard()
      Description copied from class: LinuxOSProcess
      Queries the hard open file limit for the current process via native getrlimit.
      Specified by:
      queryRlimitHard in class LinuxOSProcess
      Returns:
      the hard limit value