aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/_posts/snippets/gdb_sleep_all/gdb_sleep_all.sh
diff options
context:
space:
mode:
Diffstat (limited to '_posts/snippets/gdb_sleep_all/gdb_sleep_all.sh')
-rwxr-xr-x_posts/snippets/gdb_sleep_all/gdb_sleep_all.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/_posts/snippets/gdb_sleep_all/gdb_sleep_all.sh b/_posts/snippets/gdb_sleep_all/gdb_sleep_all.sh
new file mode 100755
index 0000000..e923740
--- /dev/null
+++ b/_posts/snippets/gdb_sleep_all/gdb_sleep_all.sh
@@ -0,0 +1,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