From: Chunhe Li <lichu...@huawei.com>

Only check wheather is daemon pid exist is not enough, becasue the 
pid which store in pidfile maybe assign to another process by OS. 
So it will checking failed for pid exist, but the starting process 
which own the pid is not the ovs daemon.

patch v2:
using /proc/$pid/comm check process name, instead of pidof.

Signed-off-by: Chunhe Li <lichu...@huawei.com>
Signed-off-by: Wunyunfei <wuyun...@huawei.com>
Signed-off-by: Ben Pfaff <b...@nicira.com>
---
 utilities/ovs-lib.in | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/utilities/ovs-lib.in b/utilities/ovs-lib.in
index 48d0c36..01bf404 100644
--- a/utilities/ovs-lib.in
+++ b/utilities/ovs-lib.in
@@ -128,6 +128,14 @@ pid_exists () {
     test -d /proc/"$1"
 }
 
+pid_comm_check () {
+    if [ "$1" = "`cat /proc/$2/comm`" ]; then
+        return 0
+    fi
+
+    return 1
+}
+
 start_daemon () {
     priority=$1
     wrapper=$2
@@ -244,5 +252,5 @@ daemon_status () {
 
 daemon_is_running () {
     pidfile=$rundir/$1.pid
-    test -e "$pidfile" && pid=`cat "$pidfile"` && pid_exists "$pid"
+    test -e "$pidfile" && pid=`cat "$pidfile"` && pid_exists "$pid" && 
pid_comm_check "$1" "$pid"
 } >/dev/null 2>&1
-- 
1.9.2.0


_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to