gstack isn't widely available, so provide a simple function that does
the same thing if it gstack can't be found.
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): Wed Jul 11 14:47:21 CEST 2018 on sn-devel-144
. "${CTDB_BASE}/functions"
+# type is at least mentioned in POSIX and more is portable than which(1)
+# shellcheck disable=SC2039
+if ! type gstack >/dev/null 2>&1 ; then
+ gstack ()
+ {
+ _pid="$1"
+
+ gdb -batch --quiet -nx "/proc/${_pid}/exe" "$_pid" \
+ -ex "thread apply all bt" 2>/dev/null |
+ grep '^\(#\|Thread \)'
+ }
+fi
+
# Load/cache database options from configuration file
ctdb_get_db_options
cat "/proc/${pid}/stack"
else
gstack "$pid"
- # gcore -o /var/log/core-deadlock-ctdb $pid
fi
done
fi