aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/_posts/snippets
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2022-09-07 16:01:12 +0200
committerEgor Tensin <Egor.Tensin@gmail.com>2022-09-07 16:01:12 +0200
commit346637cb93ae39223f91f318bf265a1b7ba87abb (patch)
tree54583e7941ff4cc1982868bc43e27b1ce5d4cdf1 /_posts/snippets
parentREADME: update (diff)
downloadblog-346637cb93ae39223f91f318bf265a1b7ba87abb.tar.gz
blog-346637cb93ae39223f91f318bf265a1b7ba87abb.zip
add "Pause all userspace processes"
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