summaryrefslogtreecommitdiffstats
path: root/bin/backtrace
diff options
context:
space:
mode:
Diffstat (limited to 'bin/backtrace')
-rwxr-xr-xbin/backtrace16
1 files changed, 16 insertions, 0 deletions
diff --git a/bin/backtrace b/bin/backtrace
new file mode 100755
index 0000000..f8582ec
--- /dev/null
+++ b/bin/backtrace
@@ -0,0 +1,16 @@
+#! /bin/sh
+set -euf
+
+pid=$$
+while :; do
+ cd /proc/$pid
+ cmdline=$(cat cmdline | sed 's/\0/ /g;s/ $//')
+ ppid=$(grep PPid status | awk '{print$2}')
+ printf '%5d %s\n' $pid "$cmdline"
+ if [ $pid = 1 ]; then
+ break
+ else
+ pid=$ppid
+ fi
+done \
+ | tac