Class AbstractProcOSProcess
- All Implemented Interfaces:
OSProcess
- Direct Known Subclasses:
AixOSProcess, SolarisOSProcess
/proc-filesystem Unix OSProcess implementations (Solaris and AIX). Both read process
info from /proc, enumerate threads from /proc/<pid>/lwp, count open files from
/proc/<pid>/fd, determine bitness from pflags, and fall back to a truncated command line. Subclasses
supply their native argument/environment read, their OSThread factory, and their platform-specific
updateAttributes().-
Nested Class Summary
Nested classes/interfaces inherited from interface OSProcess
OSProcess.StateModifier and TypeInterfaceDescriptionstatic enumProcess and Thread Execution States -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected Stringprotected longprotected longprotected Stringprotected StringFields inherited from class AbstractOSProcess
bytesRead, bytesWritten, kernelTime, name, parentProcessID, path, priority, startTime, state, threadCount, upTime, userTime, virtualSizeModifier and TypeFieldDescriptionprotected longprotected longprotected longprotected Stringprotected intprotected Stringprotected intprotected longprotected OSProcess.Stateprotected intprotected longprotected longprotected long -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract OSThreadcreateThread(int lwpid) Creates a platform-specificOSThreadfor the given lwpid of this process.Makes a best effort attempt to get a list of the the command-line arguments of the process.intAttempts to get the bitness (32 or 64) of the process.Gets the process command line used to start the process, including arguments if available to be determined.Makes a best effort attempt to obtain the current working directory for the process.Makes a best effort attempt to obtain the environment variables of the process.getGroup()Gets the group under which the process is executing.Gets the group id under which the process is executing.longGets the number of open file handles (or network connections) that belongs to the process.longReturns an estimate of the portion of physical memory (RAM) uniquely attributed to this process.longReturns the total amount of physical memory (RAM) currently mapped to the process's address space.Retrieves the threads of the process and their details.getUser()Gets the user name of the process owner.Gets the user id of the process owner.Reads this process's argument list and environment.Methods inherited from class AbstractOSProcess
getBytesRead, getBytesWritten, getKernelTime, getName, getParentProcessID, getPath, getPriority, getProcessCpuLoadBetweenTicks, getProcessCpuLoadCumulative, getProcessID, getStartTime, getState, getThreadCount, getUpTime, getUserTime, getVirtualSize, toStringModifier and TypeMethodDescriptionlongGets the bytes read by the process.longGets the bytes written by the process.longGets kernel/system (privileged) time used by the process.getName()Gets the name of the process, often the executable program.intGets the process ID of this process's parent.getPath()Gets the full filesystem path of the executing process.intGets the priority of this process.doublegetProcessCpuLoadBetweenTicks(OSProcess priorSnapshot) Gets CPU usage of this process since a previous snapshot of the same process, provided as a parameter.doubleGets cumulative CPU usage of this process.intGets the process ID.longGets the process start time.getState()Gets the process state.intGets the number of threads being executed by this process.longGets up time / elapsed time since the process started.longGets user time used by the process.longGets the Virtual Memory Size (VSZ).toString()Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface OSProcess
getAffinityMask, getContextSwitches, getHardOpenFileLimit, getInvoluntaryContextSwitches, getMajorFaults, getMinorFaults, getSoftOpenFileLimit, getVoluntaryContextSwitches, updateAttributesModifier and TypeMethodDescriptionlongGets the process affinity mask for this process.default longA snapshot of the context switches the process has done, equal to the sum ofOSProcess.getVoluntaryContextSwitches()andOSProcess.getInvoluntaryContextSwitches()on platforms that provide the split.longGets the hard limit for open file handles (or network connections) that belong to the given process.default longThe number of involuntary context switches the process has made.default longGets the number of major (hard) faults the process has made which have required loading a memory page from disk.default longGets the number of minor (soft) faults the process has made which have not required loading a memory page from disk.longGets the soft limit for open file handles (or network connections) of the given process.default longThe number of voluntary context switches the process has made.booleanAttempts to update process attributes.
-
Field Details
-
commandLineBackup
-
user
-
userID
-
group
-
groupID
-
residentSetSize
protected long residentSetSize -
privateResidentMemory
protected long privateResidentMemory
-
-
Constructor Details
-
AbstractProcOSProcess
protected AbstractProcOSProcess(int pid)
-
-
Method Details
-
getCommandLine
Description copied from interface:OSProcessGets the process command line used to start the process, including arguments if available to be determined. This method generally returns the same information asOSProcess.getArguments()in a more user-readable format, and is more robust to non-elevated access.The format of this string is platform-dependent, may be truncated, and may require the end user to parse the result. Users should generally prefer
OSProcess.getArguments()which already parses the results, and use this method as a backup.On AIX and Solaris, the string may be truncated to 80 characters if there was insufficient permission to read the process memory.
On Windows, attempts to retrieve the value from process memory, which requires that the process be owned by the same user as the executing process, or elevated permissions, and additionally requires the target process to have the same bitness (e.g., this will fail on a 32-bit process if queried by 64-bit and vice versa). If reading process memory fails, by default, performs a single WMI query for this process, with some latency. If this method will be frequently called for multiple processes, see the configuration file to enable a batch query mode to improve performance via caching, or configure the option via
GlobalConfigbefore instantiating anyOSProcessobject.- Returns:
- the process command line.
-
getArguments
Description copied from interface:OSProcessMakes a best effort attempt to get a list of the the command-line arguments of the process. Returns the same information asOSProcess.getCommandLine()but parsed to a list. May require elevated permissions or same-user ownership.- Returns:
- A list of Strings representing the arguments. May return an empty list if there was a failure (for example, because the process is already dead or permission was denied).
-
getEnvironmentVariables
Description copied from interface:OSProcessMakes a best effort attempt to obtain the environment variables of the process. May require elevated permissions or same-user ownership.- Returns:
- A map representing the environment variables and their values. May return an empty map if there was a failure (for example, because the process is already dead or permission was denied).
-
getCurrentWorkingDirectory
-
getUser
-
getUserID
-
getGroup
Description copied from interface:OSProcessGets the group under which the process is executing.On Windows systems, populating this value for processes other than the current user requires administrative privileges (and still may fail for some system processes) and can incur significant latency. When successful, returns a the default primary group with access to this process, corresponding to the SID in
OSProcess.getGroupID().- Returns:
- the group.
-
getGroupID
Description copied from interface:OSProcessGets the group id under which the process is executing.On Windows systems, populating this value for processes other than the current user requires administrative privileges (and still may fail for some system processes) and can incur significant latency. When successful, returns the default primary group SID with access to this process, corresponding to the name in
OSProcess.getGroup().- Returns:
- the groupID.
-
getResidentMemory
public long getResidentMemory()Description copied from interface:OSProcessReturns the total amount of physical memory (RAM) currently mapped to the process's address space. This value represents the Resident Set Size (RSS) and includes both private memory and memory shared with other processes (such as shared libraries). This aligns with the reporting behavior of standard command-line utilities likepsandtop.On Linux, returns the RSS value from
/proc/[pid]/stat, which may be inaccurate because of a kernel-internal scalability optimization. If accurate values are required, read/proc/[pid]/smapsusingFileUtil#getKeyValueMapFromFile(String, String).- Returns:
- The resident set size in bytes.
-
getPrivateResidentMemory
public long getPrivateResidentMemory()Description copied from interface:OSProcessReturns an estimate of the portion of physical memory (RAM) uniquely attributed to this process. This metric excludes shared libraries and other memory segments mapped by multiple processes, providing a more accurate representation of the process's individual impact on system resources. This value aligns with the primary "Memory" column in graphical system monitors, such as Windows Task Manager, macOS Activity Monitor, and the GNOME System Monitor.- Returns:
- The private or "footprint" resident memory in bytes if available. Defaults to
OSProcess.getResidentMemory()otherwise.
-
getOpenFiles
public long getOpenFiles()Description copied from interface:OSProcessGets the number of open file handles (or network connections) that belongs to the process.On FreeBSD and Solaris, this value is only populated if information for a single process id is requested.
- Returns:
- open files or -1 if unknown or not supported
-
getBitness
public int getBitness()Description copied from interface:OSProcessAttempts to get the bitness (32 or 64) of the process.- Returns:
- The bitness, if able to be determined, 0 otherwise.
-
getThreadDetails
-
queryCommandlineEnvironment
-
createThread
-