Class FstatUtil

java.lang.Object
oshi.util.common.platform.unix.netbsd.FstatUtil

@ThreadSafe public final class FstatUtil extends Object
Reads from fstat and related utilities on NetBSD.
  • Method Details

    • getCwd

      public static String getCwd(int pid)
      Gets current working directory info.
      Parameters:
      pid - a process ID
      Returns:
      the current working directory for that process.
    • parseCwdFromFstat

      public static String parseCwdFromFstat(List<String> fstatLines)
      Parses fstat -p <pid> output to find the wd row and return the path column.
      Parameters:
      fstatLines - lines returned by fstat -p <pid>
      Returns:
      the working directory string, or empty if no wd row is found
    • getOpenFiles

      public static long getOpenFiles(int pid)
      Gets open number of files.
      Parameters:
      pid - The process ID
      Returns:
      the number of open files.
    • parseOpenFiles

      public static long parseOpenFiles(List<String> fstatLines)
      Counts open file descriptor rows in fstat -p <pid> output (ignoring the header).
      Parameters:
      fstatLines - lines returned by fstat -p <pid>
      Returns:
      the number of open files (rows minus 1 for the header), or 0 if header alone or empty