aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/_posts/2022-09-07-gdb-sleep-all.md
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--_posts/2022-09-07-gdb-sleep-all.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/_posts/2022-09-07-gdb-sleep-all.md b/_posts/2022-09-07-gdb-sleep-all.md
new file mode 100644
index 0000000..b4915d3
--- /dev/null
+++ b/_posts/2022-09-07-gdb-sleep-all.md
@@ -0,0 +1,35 @@
+---
+title: Pause all userspace processes
+excerpt: >
+ How do you pause all userspace processes for a certain amount of time?
+snippets_root_directory: snippets/gdb_sleep_all
+snippets_language: bash
+snippets:
+ main:
+ - gdb_sleep_all.sh
+ gdb:
+ - sleep.gdb
+---
+If you need to debug some kind of monitoring system (or just have some fun),
+you might want to pause all userspace processes for a certain number of seconds
+(to measure delays, etc.).
+
+You can easily do this using GDB like this:
+
+{% include jekyll-theme/snippets/section.html section_id='main' %}
+
+sleep.gdb is a very simple GDB script; it basically sleeps for a determined
+amount of seconds:
+
+{% include jekyll-theme/snippets/section.html section_id='gdb' %}
+
+You can simply run
+
+ sudo ./gdb_sleep_all.sh
+
+and all of your userspace processes should be frozen for 30 seconds.
+
+On a couple of servers, this worked quite well; not so well on my laptop with
+Xfce installed.
+Obviously, this would require a bit of work to adapt for containers as well.
+Otherwise, pretty neat, huh?