1
0
mirror of https://github.com/samba-team/samba.git synced 2025-08-02 00:22:11 +03:00

ctdb-scripts: Provide a gstack function if gstack is not available

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
This commit is contained in:
Martin Schwenke
2017-12-02 20:06:25 +11:00
committed by Amitay Isaacs
parent 451c6b668f
commit 4628afa3f5

View File

@ -12,6 +12,19 @@
. "${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
@ -72,7 +85,6 @@ ctdb_get_db_options
cat "/proc/${pid}/stack"
else
gstack "$pid"
# gcore -o /var/log/core-deadlock-ctdb $pid
fi
done
fi