[ovs-dev] [PATCH v2] ovs-lib.in:Add process name checking when start ovs service

lichunhe at huawei.com lichunhe at huawei.com
Mon Aug 4 07:19:16 UTC 2014


From: Chunhe Li <lichunhe at 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 <lichunhe at huawei.com>
Signed-off-by: Wunyunfei <wuyunfei at huawei.com>
Signed-off-by: Ben Pfaff <blp at 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





More information about the dev mailing list