Class FstatUtil
java.lang.Object
oshi.util.common.platform.unix.openbsd.FstatUtil
Reads from fstat.
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetCwd(int pid) Gets current working directory info (usingpsactually).static longgetOpenFiles(int pid) Gets open number of files.static longparseOpenFiles(List<String> fstatLines) Counts open file descriptor rows infstat -sp <pid>output (OpenBSD format), excluding rows whose fifth column matchespipeorunix, and subtracting the header row.
-
Method Details
-
getCwd
Gets current working directory info (usingpsactually).- Parameters:
pid- a process ID- Returns:
- the current working directory for that process.
-
getOpenFiles
public static long getOpenFiles(int pid) Gets open number of files.- Parameters:
pid- The process ID- Returns:
- the number of open files.
-
parseOpenFiles
Counts open file descriptor rows infstat -sp <pid>output (OpenBSD format), excluding rows whose fifth column matchespipeorunix, and subtracting the header row.- Parameters:
fstatLines- lines returned byfstat -sp <pid>- Returns:
- the number of open files (counted rows minus 1 for the header);
0for empty or header-only input
-