20: def getpid
21: @resource.fail "Either stop/status commands or a pattern must be specified" unless @resource[:pattern]
22: ps = Facter["ps"].value
23: @resource.fail "You must upgrade Facter to a version that includes 'ps'" unless ps and ps != ""
24: regex = Regexp.new(@resource[:pattern])
25: self.debug "Executing '#{ps}'"
26: IO.popen(ps) { |table|
27: table.each { |line|
28: if regex.match(line)
29: ary = line.sub(/^\s+/, '').split(/\s+/)
30: return ary[1]
31: end
32: }
33: }
34:
35: nil
36: end