OS process
Represents a process in the operating system, providing details about the process, including its name, ID, state, resources usage, and more
Original source
The operating system process information are retrieved from OperatingSystem.OSProcess interface
KInfo's source
Properties
name
The name of the process
path
The path to the executable of the process
commandLine
The full command line that was used to start the process
val commandLine: String = currentProcess.commandLine
println(commandLine) // e.g. /usr/bin/java -jar myapp.jar --port 8080
arguments
The arguments passed to the process when it was started
val arguments: List<String> = currentProcess.arguments
println(arguments) // e.g. ["-jar", "myapp.jar", "--port", "8080"]
environmentVariables
A map of environment variables used by the process
val environmentVariables: List<String> = currentProcess.environmentVariables
println(environmentVariables)
// e.g. {"PATH"="/usr/bin:/bin", "JAVA_HOME"="/usr/lib/jvm/java-17-openjdk"}
currentWorkingDirectory
The current working directory of the process
val currentWorkingDirectory: String = currentProcess.currentWorkingDirectory
println(currentWorkingDirectory) // e.g. /home/user/app
user
The user running the process
userId
The ID of the user running the process
group
The group associated with the process
groupId
The ID of the group associated with the process
state
The state of the process (e.g., running, sleeping)
State entries
| State | Description |
|---|---|
| NEW | Intermediate state in process creation |
| RUNNING | Actively executing process |
| SLEEPING | Interruptible sleep state |
| WAITING | Blocked, uninterruptible sleep state |
| ZOMBIE | Intermediate state in process termination |
| STOPPED | Stopped by the user, such as for debugging |
| OTHER | Other or unknown states not defined |
| INVALID | The state resulting if the process fails to update statistics, probably due to termination |
| SUSPENDED | Special case of waiting if the process has been intentionally suspended (Windows only) |
processId
The unique identifier for the process
parentProcessId
The process ID of the parent process
threadCount
The number of threads in the process
priority
The priority of the process
virtualSize
The virtual memory size of the process, in bytes
residentSetSize
The resident set size of the process, in bytes (physical memory used)
val residentSetSize: Long = currentProcess.residentSetSize
println(residentSetSize) // e.g. 128000000
kernelTime
The amount of time the process has spent in kernel mode, in milliseconds
userTime
The amount of time the process has spent in user mode, in milliseconds
startTime
The time when the process started, in milliseconds since the Unix epoch
bytesRead
The number of bytes read by the process
bytesWritten
The number of bytes written by the process
openFiles
The number of open files used by the process
softOpenFileLimit
The soft limit on the number of files the process can open
val softOpenFileLimit: Long = currentProcess.softOpenFileLimit
println(softOpenFileLimit) // e.g. 1024
hardOpenFileLimit
The hard limit on the number of files the process can open
val hardOpenFileLimit: Long = currentProcess.hardOpenFileLimit
println(hardOpenFileLimit) // e.g. 4096
processCpuLoadCumulative
The cumulative CPU load of the process as a percentage
val processCpuLoadCumulative: Long = currentProcess.processCpuLoadCumulative
println(processCpuLoadCumulative) // e.g. 12.7
processCpuLoadBetweenTicks
The CPU load of the process between two ticks, as a percentage
val processCpuLoadBetweenTicks: Long = currentProcess.processCpuLoadBetweenTicks
println(processCpuLoadBetweenTicks) // e.g. 8.4
bitness
The bitness of the process (e.g., 32-bit, 64-bit)
affinityMask
The CPU affinity mask for the process
updateAttributes
A flag indicating whether the process attributes should be updated
val updateAttributes: Boolean = currentProcess.updateAttributes
println(updateAttributes) // e.g. 255
threadDetails
The list of thread associated with the process
minorFaults
The number of minor page faults for the process
majorFaults
The number of major page faults for the process
contextSwitches
The number of context switches for the process