]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
init-ceph: don't use procfs to check if daemon is running
authorYan, Zheng <zyan@redhat.com>
Thu, 23 Jul 2015 07:05:33 +0000 (15:05 +0800)
committerKefu Chai <kchai@redhat.com>
Mon, 31 Aug 2015 08:00:24 +0000 (16:00 +0800)
use ps(1) instead, which is portable

Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/init-ceph.in

index 82a4fd5e889c63613f520b6103a594c106478a94..22f595ad2b51255b2de5abb1ffb5aa95cd36d42d 100755 (executable)
@@ -61,8 +61,8 @@ signal_daemon() {
     [ -z "$action" ] && action="Stopping"
     printf "$action Ceph $name on $host..."
     do_cmd "if [ -e $pidfile ]; then
-        pid=`cat $pidfile`
-        if [ -e /proc/\$pid ] && grep -q $daemon /proc/\$pid/cmdline ; then
+        pid=\`cat $pidfile\`
+        if ps -p \$pid -o args= | grep -q $daemon; then
            cmd=\"kill $signal \$pid\"
            printf \"\$cmd...\"
            \$cmd
@@ -78,7 +78,7 @@ daemon_is_running() {
     pidfile=$4
     do_cmd "[ -e $pidfile ] || exit 1   # no pid, presumably not running
        pid=\`cat $pidfile\`
-       [ -e /proc/\$pid ] && grep -q $daemon /proc/\$pid/cmdline && grep -qwe -i.$daemon_id /proc/\$pid/cmdline && exit 0 # running
+       ps -p \$pid -o args= | grep $daemon | grep -qwe -i.$daemon_id && exit 0 # running
         exit 1  # pid is something else" "" "okfail"
 }
 
@@ -92,7 +92,7 @@ stop_daemon() {
     printf "$action Ceph $name on $host..."
     do_cmd "if [ -e $pidfile ] ; then 
        pid=\`cat $pidfile\`
-       while [ -e /proc/\$pid ] && grep -q $daemon /proc/\$pid/cmdline ; do
+       while ps -p \$pid -o args= | grep -q $daemon; do
            cmd=\"kill $signal \$pid\"
            printf \"\$cmd...\"
            \$cmd