From 6c22e057cc45e9bda5c110815aeee12bfc7e2be5 Mon Sep 17 00:00:00 2001 From: Bob Lantz <rlantz@cs.stanford.edu> Date: Fri, 12 Apr 2013 13:30:50 -0700 Subject: [PATCH] Avoid false matches and detect multiple host processes --- util/m | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/util/m b/util/m index 9757c2ce..002557ed 100755 --- a/util/m +++ b/util/m @@ -9,10 +9,16 @@ else host=$1 fi -pid=`pgrep -f mininet:$host` +pid=`ps ax | grep mininet:$host | grep bash | awk '{print $1};'` + +if echo $pid | grep -q ' '; then + echo "Error: found multiple mininet:$host processes" + exit 2 +fi + if [ "$pid" == "" ]; then echo "Could not find Mininet host $host" - exit 2 + exit 3 fi if [ -z $2 ]; then -- GitLab