From 712d50dea835a434f08986bbc54760ac1450cd2e Mon Sep 17 00:00:00 2001 From: Adrian Cole Date: Thu, 7 Jul 2011 01:10:57 -0700 Subject: [PATCH] avoid finding yourself when looking for a process match --- scriptbuilder/src/main/resources/functions/findPid.sh | 2 +- scriptbuilder/src/test/resources/test_find_pid.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scriptbuilder/src/main/resources/functions/findPid.sh b/scriptbuilder/src/main/resources/functions/findPid.sh index 2285cd06b9..1018c385ac 100644 --- a/scriptbuilder/src/main/resources/functions/findPid.sh +++ b/scriptbuilder/src/main/resources/functions/findPid.sh @@ -5,7 +5,7 @@ function findPid { return 1 } local PATTERN="$1"; shift - local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` [ -n "$_FOUND" ] && { export FOUND_PID=$_FOUND return 0 diff --git a/scriptbuilder/src/test/resources/test_find_pid.sh b/scriptbuilder/src/test/resources/test_find_pid.sh index e3364ce2de..fc29b66050 100644 --- a/scriptbuilder/src/test/resources/test_find_pid.sh +++ b/scriptbuilder/src/test/resources/test_find_pid.sh @@ -14,7 +14,7 @@ function findPid { return 1 } local PATTERN="$1"; shift - local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|awk '{print $2}'` + local _FOUND=`ps auxwww|grep "$PATTERN"|grep -v " $0"|grep -v grep|grep -v $$|awk '{print $2}'` [ -n "$_FOUND" ] && { export FOUND_PID=$_FOUND return 0