struct Hardware::PID
- Hardware::PID
- Struct
- Value
- Object
Overview
All informations related to the Processes running on your sytem, defined by Process IDentifiers.
pid = Hardware::PID.new # Default is Process.pid
app = Hardware::PID.new "firefox" # Take the first matching PID
Defined in:
pid.crConstructors
-
.new(number : Int64 = Process.pid)
Creates a new
Hardware::PID
. -
.new(executable : String)
Creates a new
Hardware::PID
by finding theexecutable
's pid.
Class Method Summary
-
.each(& : PID -> ) : Nil
Yields a
Hardware::PID
for each PID present on the system. -
.get_pids(executable : String, & : Int64 -> )
Yield each pids corresponding to a given
executable
name.
Instance Method Summary
-
#cmdline : String
Returns
/proc/``#pid``/cmdline
. -
#command : String
Returns a
String
representation of/proc/``#pid``/cmdline
. -
#exe : String
Returns
/proc/``#pid``/exe
if readable. - #exists? : Bool
-
#memory : Int32
Returns the actual memory used by the process.
- #name : String
-
#net : Net
Returns
Hardware::Net
for#pid
-
#number : Int64
Pid number
-
#stat(cpu : CPU | Nil = CPU.new) : Stat
Returns a parsed
/proc/``#pid``/stat
. -
#statm : Array(Int32)
Returns a parsed
/proc/``#pid``/statm
. -
#status : Status
Returns a parsed
/proc/``#pid``/status
.
Constructor Detail
Class Method Detail
Yields a Hardware::PID
for each PID present on the system.
Yield each pids corresponding to a given executable
name.
Instance Method Detail
Returns a parsed /proc/``#pid``/stat
.
Have CPU information of the process.
pid_stat = Hardware::PID.new.stat
loop do
sleep 1
p pid_stat.cpu_usage! # => 1.5
end