stockholm/bin/backtrace

17 lines
261 B
Plaintext
Raw Normal View History

2015-05-21 00:19:23 +00:00
#! /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