aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/_posts/snippets
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x_posts/snippets/gdb_sleep_all/gdb_sleep_all.sh17
-rw-r--r--_posts/snippets/gdb_sleep_all/sleep.gdb2
2 files changed, 19 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
diff --git a/_posts/snippets/gdb_sleep_all/sleep.gdb b/_posts/snippets/gdb_sleep_all/sleep.gdb
new file mode 100644
index 0000000..04f17fc
--- /dev/null
+++ b/_posts/snippets/gdb_sleep_all/sleep.gdb
@@ -0,0 +1,2 @@
+shell sleep 30
+quit