struct

Hardware::PID

Inherits Struct / Value / Object

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

Constructors

new(number : Int64 = Process.pid)

Creates a new Hardware::PID.

Source
new(executable : String)

Creates a new Hardware::PID by finding the executable's pid.

Source

Class methods

each

Yields a Hardware::PID for each PID present on the system.

Source
get_pids(executable : String, & : Int64 -> )

Yield each pids corresponding to a given executable name.

Source

Instance methods

cmdline

Returns /proc/``#pid``/cmdline.

Source
command

Returns a String representation of /proc/``#pid``/cmdline.

Source
exe

Returns /proc/``#pid``/exe if readable.

Source
exists?
Source
memory

Returns the actual memory used by the process.

Source
name

Returns the PID name based on #exe or #cmdline.

Source
net

Returns Hardware::Net for #pid

Source
number

Pid number

Source
stat(cpu : CPU | Nil = CPU.new) : Stat

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
Source
statm

Returns a parsed /proc/``#pid``/statm.

Source
status

Returns a parsed /proc/``#pid``/status.

Source

Nested types