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/opensnoop.py b/tools/opensnoop.py
index 418d47b..818c602 100755
--- a/tools/opensnoop.py
+++ b/tools/opensnoop.py
@@ -191,4 +191,7 @@
b["events"].open_perf_buffer(print_event, page_cnt=64)
start_time = datetime.now()
while not args.duration or datetime.now() - start_time < args.duration:
- b.perf_buffer_poll()
+ try:
+ b.perf_buffer_poll()
+ except KeyboardInterrupt:
+ exit()