From 1330e6670914042e0df024284011e860f92f3ae0 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Fri, 17 Aug 2012 20:26:22 -0400 Subject: [PATCH] tweak service module pattern= logic so ./hacking/test-module does not give false positives --- service | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/service b/service index 5010887056c..c6e48f759be 100755 --- a/service +++ b/service @@ -68,21 +68,26 @@ def _get_service_status(name, pattern): # If pattern is provided, search for that # before checking initctl, service output, and other tricks if pattern is not None: + psbin = '/bin/ps' if not os.path.exists(psbin): if os.path.exists('/usr/bin/ps'): psbin = '/usr/bin/ps' else: psbin = None + if psbin is not None: (rc, psout, pserr) = _run('%s %s' % (psbin, PS_OPTIONS)) # If rc is 0, set running as appropriate # If ps command fails, fall back to other means. if rc == 0: - if pattern in psout: - running = True - else: - running = False + running = False + lines = psout.split("\n") + for line in lines: + if pattern in line and not "pattern=" in line: + # so as to not confuse ./hacking/test-module + running = True + break # Check if we got upstart on the system and then the job state if INITCTL != None and running is None: