Tools: properly handle the keyboard interrupt (#2083)
Many tools rely on the user to type Ctrl-C to end, but don't actually
catch the keyboard interrupt and thus show an ugly backtrace when it
happens. Let's catch the interrupt.
diff --git a/tools/oomkill.py b/tools/oomkill.py
index 0677e49..db3a537 100755
--- a/tools/oomkill.py
+++ b/tools/oomkill.py
@@ -77,4 +77,7 @@
print("Tracing OOM kills... Ctrl-C to stop.")
b["events"].open_perf_buffer(print_event)
while 1:
- b.perf_buffer_poll()
+ try:
+ b.perf_buffer_poll()
+ except KeyboardInterrupt:
+ exit()