git://git.onelab.eu
/
sliver-openvswitch.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
a835b06
)
ovs-lib: Allow "status" command to work as non-root.
author
Ben Pfaff
<blp@nicira.com>
Fri, 15 Jul 2011 21:53:11 +0000
(14:53 -0700)
committer
Ben Pfaff
<blp@nicira.com>
Mon, 18 Jul 2011 18:37:46 +0000
(11:37 -0700)
utilities/ovs-lib.sh.in
patch
|
blob
|
history
diff --git
a/utilities/ovs-lib.sh.in
b/utilities/ovs-lib.sh.in
index
179d85e
..
f53d4af
100644
(file)
--- a/
utilities/ovs-lib.sh.in
+++ b/
utilities/ovs-lib.sh.in
@@
-84,6
+84,12
@@
fi
## Daemons ##
## ------- ##
## Daemons ##
## ------- ##
+pid_exists () {
+ # This is better than "kill -0" because it doesn't require permission to
+ # send a signal (so daemon_status in particular works as non-root).
+ test -d /proc/"$1"
+}
+
start_daemon () {
priority=$1
shift
start_daemon () {
priority=$1
shift
@@
-128,7
+134,7
@@
stop_daemon () {
return 1
;;
*)
return 1
;;
*)
- if
kill -0
$pid >/dev/null 2>&1; then
+ if
pid_exists
$pid >/dev/null 2>&1; then
sleep $action
else
return 0
sleep $action
else
return 0
@@
-145,7
+151,7
@@
daemon_status () {
pidfile=$rundir/$1.pid
if test -e "$pidfile"; then
if pid=`cat "$pidfile"`; then
pidfile=$rundir/$1.pid
if test -e "$pidfile"; then
if pid=`cat "$pidfile"`; then
- if
kill -0
"$pid"; then
+ if
pid_exists
"$pid"; then
echo "$1 is running with pid $pid"
return 0
else
echo "$1 is running with pid $pid"
return 0
else
@@
-162,5
+168,5
@@
daemon_status () {
daemon_is_running () {
pidfile=$rundir/$1.pid
daemon_is_running () {
pidfile=$rundir/$1.pid
- test -e "$pidfile" && pid=`cat "$pidfile"` &&
kill -0
"$pid"
+ test -e "$pidfile" && pid=`cat "$pidfile"` &&
pid_exists
"$pid"
} >/dev/null 2>&1
} >/dev/null 2>&1