Class OpenBsdOperatingSystem

All Implemented Interfaces:
OperatingSystem

@ThreadSafe public abstract class OpenBsdOperatingSystem extends BsdOperatingSystem
Abstract base shared by the OpenBSD OperatingSystem implementations (JNA and FFM). The cross-BSD-common pieces live in BsdOperatingSystem; this layer adds the OpenBSD ps process enumeration, the ps -axHo tid thread count, the text-parsed boot time, and the (non-native) internet protocol stats and network params. The native bits (the OSProcess and FileSystem factories, getpid/getthrid, and the sysctl version query) are provided by the JNA and FFM subclasses.
  • Constructor Details

    • OpenBsdOperatingSystem

      public OpenBsdOperatingSystem()
  • Method Details

    • getInternetProtocolStats

      public InternetProtocolStats getInternetProtocolStats()
      Description copied from interface: OperatingSystem
      Instantiates a InternetProtocolStats object.
      Returns:
      a InternetProtocolStats object.
    • getNetworkParams

      public NetworkParams getNetworkParams()
      Description copied from interface: OperatingSystem
      Instantiates a NetworkParams object.
      Returns:
      A NetworkParams object.
    • getProcessListFromPS

      protected List<OSProcess> getProcessListFromPS(int pid)
      Description copied from class: BsdOperatingSystem
      Enumerates processes (or a single process when pid >= 0) via the platform's ps command.
      Specified by:
      getProcessListFromPS in class BsdOperatingSystem
      Parameters:
      pid - the process ID, or -1 for all processes
      Returns:
      the process list
    • getCurrentThread

      public OSThread getCurrentThread()
      Description copied from interface: OperatingSystem
      Makes a best effort to get the current thread. May not be useful in a multithreaded environment. The thread returned may have been short lived and no longer exist.

      On macOS, returns the oldest thread in the calling process.

      Returns:
      the current thread if known; an invalid thread otherwise.
    • getThreadCount

      public int getThreadCount()
      Description copied from interface: OperatingSystem
      Get the number of threads currently running
      Specified by:
      getThreadCount in interface OperatingSystem
      Overrides:
      getThreadCount in class BsdOperatingSystem
      Returns:
      The number of threads running
    • queryBootTime

      protected long queryBootTime()
      Description copied from class: BsdOperatingSystem
      Queries the system boot time in seconds since the epoch.
      Specified by:
      queryBootTime in class BsdOperatingSystem
      Returns:
      the boot time in seconds
    • createProcess

      protected abstract OSProcess createProcess(int pid, Map<BsdPsKeyword, String> psMap)
      Creates a backend-specific OSProcess from a parsed ps row.
      Parameters:
      pid - the process ID
      psMap - the parsed ps columns for this process
      Returns:
      a new OSProcess