blob: 15d60a9b4d115e518a69253721f30f07629b33d1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
#! /bin/sh
set -euf
exec >&2
pid=$$
while :; do
cd /proc/$pid
cmdline=$(cat cmdline | tr '\0' ' ' | sed 's/ $//')
ppid=$(grep PPid status | awk '{print$2}')
printf '%5d %s\n' $pid "$cmdline"
if [ $pid = 1 ]; then
break
else
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
|