Class: Flatware::Pid
- Inherits:
-
Struct
- Object
- Struct
- Flatware::Pid
- Defined in:
- lib/flatware/pid.rb
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#pgid ⇒ Object
Returns the value of attribute pgid.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#ppid ⇒ Object
Returns the value of attribute ppid.
Class Method Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command
17 18 19 |
# File 'lib/flatware/pid.rb', line 17 def command @command end |
#pgid ⇒ Object
Returns the value of attribute pgid
17 18 19 |
# File 'lib/flatware/pid.rb', line 17 def pgid @pgid end |
#pid ⇒ Object
Returns the value of attribute pid
17 18 19 |
# File 'lib/flatware/pid.rb', line 17 def pid @pid end |
#ppid ⇒ Object
Returns the value of attribute ppid
17 18 19 |
# File 'lib/flatware/pid.rb', line 17 def ppid @ppid end |
Class Method Details
.pids(&block) ⇒ Object
18 19 20 |
# File 'lib/flatware/pid.rb', line 18 def self.pids(&block) ps.select(&block).map(&:pid) end |
.ps ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/flatware/pid.rb', line 22 def self.ps args = ['-o', members.join(',')] args += { 'Darwin' => %w[-c] }.fetch(Etc.uname.fetch(:sysname), []) IO .popen(['ps', *args]) .readlines .map do |row| fields = row.strip.split(/\s+/, 4) new(*fields.take(3).map(&:to_i), fields.last) end end |
Instance Method Details
#pids_of_group(group_pid) ⇒ Object
35 36 37 38 39 |
# File 'lib/flatware/pid.rb', line 35 def pids_of_group(group_pid) ps .select { |pid| pid.pgid == group_pid } .map(&:pid) end |