aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-06-04 14:04:41 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-06-07 10:04:53 -0400
commitc3fb083d902e20a764a8d46a1fcfaede67df570b (patch)
treeffcb34f9ffdf205cc2f1a87d4067489423612bb9
parent08e77f6f601736df1a53c33c4e13bc3fb2e98af4 (diff)
trace-cmd: Add signal handler for SIGINT in trace-cmd read
When python plugins are loaded, they override SIGINT, and it becomes quite annoying that you can't stop a print with Ctrl-C. By adding a signal handler for SIGINT, we can stop the output with Ctrl-C. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-read.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/trace-read.c b/trace-read.c
index bbe34ba..a5c27e2 100644
--- a/trace-read.c
+++ b/trace-read.c
@@ -32,6 +32,7 @@
32#include <sys/mman.h> 32#include <sys/mman.h>
33#include <pthread.h> 33#include <pthread.h>
34#include <fcntl.h> 34#include <fcntl.h>
35#include <signal.h>
35#include <unistd.h> 36#include <unistd.h>
36#include <ctype.h> 37#include <ctype.h>
37#include <errno.h> 38#include <errno.h>
@@ -553,6 +554,12 @@ struct tracecmd_input *read_trace_header(void)
553 return tracecmd_alloc_fd(input_fd); 554 return tracecmd_alloc_fd(input_fd);
554} 555}
555 556
557static void sig_end(int sig)
558{
559 fprintf(stderr, "trace-cmd: Received SIGINT\n");
560 exit(0);
561}
562
556void trace_report (int argc, char **argv) 563void trace_report (int argc, char **argv)
557{ 564{
558 struct tracecmd_input *handle; 565 struct tracecmd_input *handle;
@@ -574,6 +581,8 @@ void trace_report (int argc, char **argv)
574 if (strcmp(argv[1], "report") != 0) 581 if (strcmp(argv[1], "report") != 0)
575 usage(argv); 582 usage(argv);
576 583
584 signal(SIGINT, sig_end);
585
577 for (;;) { 586 for (;;) {
578 int option_index = 0; 587 int option_index = 0;
579 static struct option long_options[] = { 588 static struct option long_options[] = {