From 8ec18087109c7612553ec33d6c87aec1c7a622d1 Mon Sep 17 00:00:00 2001 From: Al Bailey Date: Wed, 4 Oct 2017 13:04:27 -0500 Subject: [PATCH] Update getpid function Enhance the getpid function to avoid matching with the "puppet apply" command --- lib/puppet/provider/service/base.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/puppet/provider/service/base.rb b/lib/puppet/provider/service/base.rb index d72d408..b8ac2eb 100644 --- a/lib/puppet/provider/service/base.rb +++ b/lib/puppet/provider/service/base.rb @@ -31,11 +31,12 @@ Puppet::Type.type(:service).provide :base, :parent => :service do def getpid @resource.fail "Either stop/status commands or a pattern must be specified" unless @resource[:pattern] regex = Regexp.new(@resource[:pattern]) + regex_pa = Regexp.new('puppet apply') ps = getps self.debug "Executing '#{ps}'" IO.popen(ps) { |table| table.each_line { |line| - if regex.match(line) + if regex.match(line) and not regex_pa.match(line) self.debug "Process matched: #{line}" ary = line.sub(/^\s+/, '').split(/\s+/) return ary[1] -- 1.8.3.1