diff options
-rw-r--r-- | tools/perf/builtin-record.c | 19 | ||||
-rw-r--r-- | tools/perf/builtin-stat.c | 2 |
2 files changed, 19 insertions, 2 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 6b0519f885e4..042117f8fffa 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -73,6 +73,7 @@ static off_t post_processing_offset; | |||
73 | 73 | ||
74 | static struct perf_session *session; | 74 | static struct perf_session *session; |
75 | static const char *cpu_list; | 75 | static const char *cpu_list; |
76 | static const char *progname; | ||
76 | 77 | ||
77 | static void advance_output(size_t size) | 78 | static void advance_output(size_t size) |
78 | { | 79 | { |
@@ -137,17 +138,29 @@ static void mmap_read(struct perf_mmap *md) | |||
137 | 138 | ||
138 | static volatile int done = 0; | 139 | static volatile int done = 0; |
139 | static volatile int signr = -1; | 140 | static volatile int signr = -1; |
141 | static volatile int child_finished = 0; | ||
140 | 142 | ||
141 | static void sig_handler(int sig) | 143 | static void sig_handler(int sig) |
142 | { | 144 | { |
145 | if (sig == SIGCHLD) | ||
146 | child_finished = 1; | ||
147 | |||
143 | done = 1; | 148 | done = 1; |
144 | signr = sig; | 149 | signr = sig; |
145 | } | 150 | } |
146 | 151 | ||
147 | static void sig_atexit(void) | 152 | static void sig_atexit(void) |
148 | { | 153 | { |
149 | if (child_pid > 0) | 154 | int status; |
150 | kill(child_pid, SIGTERM); | 155 | |
156 | if (child_pid > 0) { | ||
157 | if (!child_finished) | ||
158 | kill(child_pid, SIGTERM); | ||
159 | |||
160 | wait(&status); | ||
161 | if (WIFSIGNALED(status)) | ||
162 | psignal(WTERMSIG(status), progname); | ||
163 | } | ||
151 | 164 | ||
152 | if (signr == -1 || signr == SIGUSR1) | 165 | if (signr == -1 || signr == SIGUSR1) |
153 | return; | 166 | return; |
@@ -445,6 +458,8 @@ static int __cmd_record(int argc, const char **argv) | |||
445 | char buf; | 458 | char buf; |
446 | struct machine *machine; | 459 | struct machine *machine; |
447 | 460 | ||
461 | progname = argv[0]; | ||
462 | |||
448 | page_size = sysconf(_SC_PAGE_SIZE); | 463 | page_size = sysconf(_SC_PAGE_SIZE); |
449 | 464 | ||
450 | atexit(sig_atexit); | 465 | atexit(sig_atexit); |
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c index b5673194870a..7ce65f52415e 100644 --- a/tools/perf/builtin-stat.c +++ b/tools/perf/builtin-stat.c | |||
@@ -495,6 +495,8 @@ static int run_perf_stat(int argc __used, const char **argv) | |||
495 | if (forks) { | 495 | if (forks) { |
496 | close(go_pipe[1]); | 496 | close(go_pipe[1]); |
497 | wait(&status); | 497 | wait(&status); |
498 | if (WIFSIGNALED(status)) | ||
499 | psignal(WTERMSIG(status), argv[0]); | ||
498 | } else { | 500 | } else { |
499 | while(!done) sleep(1); | 501 | while(!done) sleep(1); |
500 | } | 502 | } |