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/inject.py b/tools/inject.py
index 741a0fb..bf07a8f 100755
--- a/tools/inject.py
+++ b/tools/inject.py
@@ -507,7 +507,10 @@
def _main_loop(self):
while True:
- self.bpf.perf_buffer_poll()
+ try:
+ self.bpf.perf_buffer_poll()
+ except KeyboardInterrupt:
+ exit()
def run(self):
self._create_probes()