summaryrefslogtreecommitdiffstats
path: root/bin/backtrace
blob: f8582ec2f03b96ae5ad2cf7381c1b61e9186a7ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
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