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