Class: ProcessInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/vcseif/utils/proctbl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fields) ⇒ ProcessInfo

Returns a new instance of ProcessInfo.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/vcseif/utils/proctbl.rb', line 17

def initialize(fields)
  @uid = 0   # default to a Windows "safe" value
  user_field = fields[0]
  @pid     =   fields[1].to_i
  @ppid    =   fields[2].to_i
  junk     =   fields[3]
  @started =   fields[4]
  @cmdline =   fields[5]
  begin
    uid = user_field.to_i
    @uid = uid
  rescue Exception => ex
    begin
      require 'etc'
      user = Etc.getpwnam(user_field)
      @uid = user.uid.to_i
    rescue
      # do nothing, we'll limp along with the default value established earlier
    end
  end
end

Instance Attribute Details

#cmdlineObject

Returns the value of attribute cmdline.



15
16
17
# File 'lib/vcseif/utils/proctbl.rb', line 15

def cmdline
  @cmdline
end

#pidObject

Returns the value of attribute pid.



15
16
17
# File 'lib/vcseif/utils/proctbl.rb', line 15

def pid
  @pid
end

#ppidObject

Returns the value of attribute ppid.



15
16
17
# File 'lib/vcseif/utils/proctbl.rb', line 15

def ppid
  @ppid
end

#startedObject

Returns the value of attribute started.



15
16
17
# File 'lib/vcseif/utils/proctbl.rb', line 15

def started
  @started
end

#uidObject

Returns the value of attribute uid.



15
16
17
# File 'lib/vcseif/utils/proctbl.rb', line 15

def uid
  @uid
end

Instance Method Details

#to_sObject



39
40
41
# File 'lib/vcseif/utils/proctbl.rb', line 39

def to_s
  "%5s %5s %5s %12s %s" % [@pid, @uid, @ppid, @started, @cmdline]
end