From: Martin Schwenke Date: Sat, 2 Dec 2017 09:06:25 +0000 (+1100) Subject: ctdb-scripts: Provide a gstack function if gstack is not available X-Git-Tag: tevent-0.9.37~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4628afa3f563924434ccae9918cf60778b8ab91f;p=thirdparty%2Fsamba.git 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 Reviewed-by: Amitay Isaacs Autobuild-User(master): Amitay Isaacs Autobuild-Date(master): Wed Jul 11 14:47:21 CEST 2018 on sn-devel-144 --- diff --git a/ctdb/config/debug_locks.sh b/ctdb/config/debug_locks.sh index 08676854088..1f89cb7353c 100755 --- a/ctdb/config/debug_locks.sh +++ b/ctdb/config/debug_locks.sh @@ -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