diff options
Diffstat (limited to 'tools/perf/builtin-record.c')
-rw-r--r-- | tools/perf/builtin-record.c | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index f4c3fbee4ba..f82480fa7f2 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -73,6 +73,7 @@ static off_t post_processing_offset; static struct perf_session *session; static const char *cpu_list; +static const char *progname; static void advance_output(size_t size) { @@ -137,17 +138,29 @@ static void mmap_read(struct perf_mmap *md) static volatile int done = 0; static volatile int signr = -1; +static volatile int child_finished = 0; static void sig_handler(int sig) { + if (sig == SIGCHLD) + child_finished = 1; + done = 1; signr = sig; } static void sig_atexit(void) { - if (child_pid > 0) - kill(child_pid, SIGTERM); + int status; + + if (child_pid > 0) { + if (!child_finished) + kill(child_pid, SIGTERM); + + wait(&status); + if (WIFSIGNALED(status)) + psignal(WTERMSIG(status), progname); + } if (signr == -1 || signr == SIGUSR1) return; @@ -446,6 +459,8 @@ static int __cmd_record(int argc, const char **argv) char buf; struct machine *machine; + progname = argv[0]; + page_size = sysconf(_SC_PAGE_SIZE); atexit(sig_atexit); @@ -514,6 +529,19 @@ static int __cmd_record(int argc, const char **argv) if (have_tracepoints(&evsel_list->entries)) perf_header__set_feat(&session->header, HEADER_TRACE_INFO); + perf_header__set_feat(&session->header, HEADER_HOSTNAME); + perf_header__set_feat(&session->header, HEADER_OSRELEASE); + perf_header__set_feat(&session->header, HEADER_ARCH); + perf_header__set_feat(&session->header, HEADER_CPUDESC); + perf_header__set_feat(&session->header, HEADER_NRCPUS); + perf_header__set_feat(&session->header, HEADER_EVENT_DESC); + perf_header__set_feat(&session->header, HEADER_CMDLINE); + perf_header__set_feat(&session->header, HEADER_VERSION); + perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY); + perf_header__set_feat(&session->header, HEADER_TOTAL_MEM); + perf_header__set_feat(&session->header, HEADER_NUMA_TOPOLOGY); + perf_header__set_feat(&session->header, HEADER_CPUID); + /* 512 kiB: default amount of unprivileged mlocked memory */ if (mmap_pages == UINT_MAX) mmap_pages = (512 * 1024) / page_size; @@ -785,6 +813,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) int err = -ENOMEM; struct perf_evsel *pos; + perf_header__set_cmdline(argc, argv); + evsel_list = perf_evlist__new(NULL, NULL); if (evsel_list == NULL) return -ENOMEM; |