Permalink
Browse files

pidof(1): was reporting child process instead of master; added

workaround.
  • Loading branch information...
1 parent 3b091a2 commit 3b07b96f89ebc52cf2864301f2157825fcc21ee4 Brane F. Gračnar committed May 18, 2011
Showing with 15 additions and 8 deletions.
  1. +15 −8 contrib/init/openvpn_auth
View
@@ -26,21 +26,28 @@ daemon_stop() {
daemon_status >/dev/null 2>&1 || return 1
# kill the pid
- if ! kill "${_PID}" >/dev/null 2>&1; then
- ERROR="Unable to send SIGTERM to pid ${_PID}"
+ if ! kill ${_PID} >/dev/null 2>&1; then
+ ERROR="Unable to send SIGTERM to pid(s): ${_PID}"
return 1
fi
# wait for termination
i=0
ok=0
while [ $i -lt 10 ]; do
- let i=$i+1
- # is thisfucker still alive?
- if ! kill -0 "${_PID}" >/dev/null 2>&1; then
- ok=1
+ i=$(($i + 1))
+ ok=1
+ for p in ${_PID}; do
+ # is thisfucker still alive?
+ if kill -0 "${_PID}" >/dev/null 2>&1; then
+ ok=0
+ break
+ fi
+ done
+ if [ "${ok}" = "1" ]; then
break
fi
+ sleep 1
done
if [ "${ok}" != "1" ]; then
ERROR="Process didn't stop."
@@ -51,7 +58,7 @@ daemon_stop() {
}
daemon_pid() {
- pidof -x -s "${DAEMON}" 2>/dev/null
+ pidof -x "${DAEMON}" | tr ' ' '\n' | sort | tr '\n' ' ' 2>/dev/null
}
daemon_status() {
@@ -60,7 +67,7 @@ daemon_status() {
ERROR="${MYNAME} is stopped."
return 1
else
- ERROR="${MYNAME} is running as pid ${_PID}."
+ ERROR="${MYNAME} is running as pid(s): ${_PID}"
return 0
fi
}

0 comments on commit 3b07b96

Please sign in to comment.