diff options
author | Ingo Molnar <mingo@elte.hu> | 2009-05-15 05:03:23 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-05-15 06:09:54 -0400 |
commit | 58d7e993b16b62d30f8ef27757614056fe4def11 (patch) | |
tree | a469295442ce5689b85581c84b24d1a9b06fc59c /Documentation/perf_counter/builtin-stat.c | |
parent | 251e8e3c7235f5944805a64f24c79fc4696793f1 (diff) |
perf stat: handle Ctrl-C
Before this change, if a long-running perf stat workload was Ctrl-C-ed,
the utility exited without displaying statistics.
After the change, the Ctrl-C gets propagated into the workload (and
causes its early exit there), but perf stat itself will still continue
to run and will display counter results.
This is useful to run open-ended workloads, let them run for
a while, then Ctrl-C them to get the stats.
[ Impact: extend perf stat with new functionality ]
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'Documentation/perf_counter/builtin-stat.c')
-rw-r--r-- | Documentation/perf_counter/builtin-stat.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Documentation/perf_counter/builtin-stat.c b/Documentation/perf_counter/builtin-stat.c index cf575c305a6c..03518d75d864 100644 --- a/Documentation/perf_counter/builtin-stat.c +++ b/Documentation/perf_counter/builtin-stat.c | |||
@@ -538,8 +538,14 @@ static void process_options(int argc, char **argv) | |||
538 | } | 538 | } |
539 | } | 539 | } |
540 | 540 | ||
541 | static void skip_signal(int signo) | ||
542 | { | ||
543 | } | ||
544 | |||
541 | int cmd_stat(int argc, char **argv, const char *prefix) | 545 | int cmd_stat(int argc, char **argv, const char *prefix) |
542 | { | 546 | { |
547 | sigset_t blocked; | ||
548 | |||
543 | page_size = sysconf(_SC_PAGE_SIZE); | 549 | page_size = sysconf(_SC_PAGE_SIZE); |
544 | 550 | ||
545 | process_options(argc, argv); | 551 | process_options(argc, argv); |
@@ -548,5 +554,15 @@ int cmd_stat(int argc, char **argv, const char *prefix) | |||
548 | assert(nr_cpus <= MAX_NR_CPUS); | 554 | assert(nr_cpus <= MAX_NR_CPUS); |
549 | assert(nr_cpus >= 0); | 555 | assert(nr_cpus >= 0); |
550 | 556 | ||
557 | /* | ||
558 | * We dont want to block the signals - that would cause | ||
559 | * child tasks to inherit that and Ctrl-C would not work. | ||
560 | * What we want is for Ctrl-C to work in the exec()-ed | ||
561 | * task, but being ignored by perf stat itself: | ||
562 | */ | ||
563 | signal(SIGINT, skip_signal); | ||
564 | signal(SIGALRM, skip_signal); | ||
565 | signal(SIGABRT, skip_signal); | ||
566 | |||
551 | return do_perfstat(argc, argv); | 567 | return do_perfstat(argc, argv); |
552 | } | 568 | } |