summaryrefslogtreecommitdiff
path: root/ctdb
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2016-10-10 14:56:18 +1100
committerAmitay Isaacs <amitay@samba.org>2016-10-14 11:54:40 +0200
commit1d2d0c34fc6e7d217f322adb6b6d3e920cbedf89 (patch)
treed369314a32d7104a3e9f2421a97aac8ce37c1ab6 /ctdb
parentfd8e562069e3c01720be62069b7d58d14c10afd5 (diff)
downloadsamba-1d2d0c34fc6e7d217f322adb6b6d3e920cbedf89.tar.gz
ctdb-scripts: Strengthen check to see if ctdbd is running
Don't just rely on the process existing. It must be called "ctdbd". Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com> Autobuild-User(master): Amitay Isaacs <amitay@samba.org> Autobuild-Date(master): Fri Oct 14 11:54:40 CEST 2016 on sn-devel-144
Diffstat (limited to 'ctdb')
-rwxr-xr-xctdb/config/ctdbd_wrapper14
1 files changed, 9 insertions, 5 deletions
diff --git a/ctdb/config/ctdbd_wrapper b/ctdb/config/ctdbd_wrapper
index 11ea59adbc4..8a9f554dd5f 100755
--- a/ctdb/config/ctdbd_wrapper
+++ b/ctdb/config/ctdbd_wrapper
@@ -31,17 +31,21 @@ ctdbd="${CTDBD:-/usr/local/sbin/ctdbd}"
# ctdbd_is_running()
# Check if ctdbd is running. ctdbd is only considered to running if
-# the PID in the PID file is active. Return true if this is the case.
-# Print the PID regardless, since it can be used to kill stale
-# processes in the session.
+# the PID in the PID file is active and is called "ctdbd". Return
+# true if this is the case. Print the PID regardless, since it can be
+# used to kill stale processes in the session.
ctdbd_is_running ()
{
if read _pid 2>/dev/null <"$pidfile" ; then
echo "$_pid"
- # Return value of kill is used
- kill -0 "$_pid" 2>/dev/null
+ # This could be optimised with ps options -q and -h.
+ # However, -q is not generally available because it is
+ # fairly new and -h is not in some older distros. The
+ # options below are portable.
+ _cmd=$(ps -p "$_pid" -o comm | tail -n +2)
+ [ "$_cmd" = "ctdbd" ]
else
# Missing/empty PID file
return 1