diff options
author | tv <tv@shackspace.de> | 2015-05-21 03:40:27 +0200 |
---|---|---|
committer | tv <tv@shackspace.de> | 2015-05-21 03:40:27 +0200 |
commit | b27ec1aafa813740941d9194f1e7e113d5de8244 (patch) | |
tree | bcc99af2eed1661b1a32dd30395d9ed98de60c66 /bin/backtrace | |
parent | d41e3a557727a4d421d2b6235d2e1e59e8b873ee (diff) |
backtrace: diverge
Diffstat (limited to 'bin/backtrace')
-rwxr-xr-x | bin/backtrace | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/bin/backtrace b/bin/backtrace index f8582ec2f..15d60a9b4 100755 --- a/bin/backtrace +++ b/bin/backtrace @@ -1,10 +1,12 @@ #! /bin/sh set -euf +exec >&2 + pid=$$ while :; do cd /proc/$pid - cmdline=$(cat cmdline | sed 's/\0/ /g;s/ $//') + cmdline=$(cat cmdline | tr '\0' ' ' | sed 's/ $//') ppid=$(grep PPid status | awk '{print$2}') printf '%5d %s\n' $pid "$cmdline" if [ $pid = 1 ]; then @@ -13,4 +15,18 @@ while :; do pid=$ppid fi done \ + | sed \ + "$(printf ' + s:\(/bin/sh \)%s/\([^ ]\+\):\e[32m\\2\e[m:g + s:%s/\([^ ]\+\):\e[32;1m\\1\e[m:g + ' \ + "$(dirname "$0" | bre-escape | sed 's/:/\\:/g')" \ + "$(dirname "$0" | bre-escape | sed 's/:/\\:/g')" \ + )" \ | tac + +ps='Press ^C to abort: ' +while :; do + printf '\e[K\e[31;1m%s\e[m' "$ps" + read -r _input +done |