aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/_posts/snippets/gdb_sleep_all/gdb_sleep_all.sh
blob: e9237401090da628a18c77c34c15dcd13f02fa07 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/env bash

set -o errexit -o nounset -o pipefail

# Select all process IDs that are _not_ children of PID 2, [kthreadd].
pids="$( ps -o pid --no-headers --ppid 2 -p 2 --deselect )"

for pid in $pids; do
	cmdline="$( cat "/proc/$pid/cmdline" | tr '\0' ' ' )" || continue
	echo ------------------------------------------------------------------
	echo "PID: $pid"
	echo "Command line: $cmdline"
	echo ------------------------------------------------------------------
	gdb -p "$pid" -x sleep.gdb -batch &
done

wait