summaryrefslogtreecommitdiff
path: root/ctdb/config
diff options
context:
space:
mode:
authorMartin Schwenke <martin@meltin.net>2014-11-17 14:15:14 +1100
committerAmitay Isaacs <amitay@samba.org>2014-11-18 06:37:44 +0100
commit7f377cf26ecec10cd77f28c1993c48337279892d (patch)
tree38da431d7959206054330057f4bed38fc516b940 /ctdb/config
parent4cd5be87daf531cb8a67f31b91cceeaf2c488127 (diff)
downloadsamba-7f377cf26ecec10cd77f28c1993c48337279892d.tar.gz
ctdb-scripts: Fix stack dumping when debugging hung scripts
There are parentheses missing that stop the default pattern from matching commands with trailing garbage (e.g. "exportfs.orig"). A careful check of POSIX (and running GNU sed with --posix) suggests that "\|" isn't a supported way of specifying alternation in a regular expression. Therefore, it is clearer to switch to extended regular expressions so that this has a chance of being portable (even though the point is to print /proc/<pid>/stack, which only works on Linux). 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): Tue Nov 18 06:37:45 CET 2014 on sn-devel-104
Diffstat (limited to 'ctdb/config')
-rwxr-xr-xctdb/config/debug-hung-script.sh9
1 files changed, 6 insertions, 3 deletions
diff --git a/ctdb/config/debug-hung-script.sh b/ctdb/config/debug-hung-script.sh
index 34e957c3cf0..3f800fc5559 100755
--- a/ctdb/config/debug-hung-script.sh
+++ b/ctdb/config/debug-hung-script.sh
@@ -1,5 +1,8 @@
#!/bin/sh
+# This script only works on Linux. Please modify (and submit patches)
+# for other operating systems.
+
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; echo "$PWD")
@@ -28,12 +31,12 @@ fi
# Check for processes matching a regular expression and print
# stack staces. This could help confirm that certain processes
# are stuck in certain places such as the cluster filesystem. The
- # regexp should separate items with "\|" and should not contain
+ # regexp must separate items with "|" and must not contain
# parentheses. The default pattern can be replaced for testing.
- default_pat='exportfs\|rpcinfo'
+ default_pat='exportfs|rpcinfo'
pat="${CTDB_DEBUG_HUNG_SCRIPT_STACKPAT:-${default_pat}}"
echo "$out" |
- sed -n "s@.*-\(.*${pat}.*\),\([0-9]*\).*@\2 \1@p" |
+ sed -r -n "s@.*-(.*(${pat}).*),([0-9]*).*@\3 \1@p" |
while read pid name ; do
trace=$(cat "/proc/${pid}/stack" 2>/dev/null)
if [ $? -eq 0 ] ; then