diff options
| -rw-r--r-- | tools/perf/builtin-record.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 63136d0534d4..265425322734 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
| @@ -402,7 +402,7 @@ static void atexit_header(void) | |||
| 402 | perf_header__write(&session->header, output, true); | 402 | perf_header__write(&session->header, output, true); |
| 403 | } | 403 | } |
| 404 | 404 | ||
| 405 | static int __cmd_record(int argc __used, const char **argv) | 405 | static int __cmd_record(int argc, const char **argv) |
| 406 | { | 406 | { |
| 407 | int i, counter; | 407 | int i, counter; |
| 408 | struct stat st; | 408 | struct stat st; |
| @@ -411,6 +411,7 @@ static int __cmd_record(int argc __used, const char **argv) | |||
| 411 | int err; | 411 | int err; |
| 412 | unsigned long waking = 0; | 412 | unsigned long waking = 0; |
| 413 | int child_ready_pipe[2], go_pipe[2]; | 413 | int child_ready_pipe[2], go_pipe[2]; |
| 414 | const bool forks = target_pid == -1 && argc > 0; | ||
| 414 | char buf; | 415 | char buf; |
| 415 | 416 | ||
| 416 | page_size = sysconf(_SC_PAGE_SIZE); | 417 | page_size = sysconf(_SC_PAGE_SIZE); |
| @@ -422,7 +423,7 @@ static int __cmd_record(int argc __used, const char **argv) | |||
| 422 | signal(SIGCHLD, sig_handler); | 423 | signal(SIGCHLD, sig_handler); |
| 423 | signal(SIGINT, sig_handler); | 424 | signal(SIGINT, sig_handler); |
| 424 | 425 | ||
| 425 | if (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0) { | 426 | if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) { |
| 426 | perror("failed to create pipes"); | 427 | perror("failed to create pipes"); |
| 427 | exit(-1); | 428 | exit(-1); |
| 428 | } | 429 | } |
| @@ -483,7 +484,7 @@ static int __cmd_record(int argc __used, const char **argv) | |||
| 483 | 484 | ||
| 484 | atexit(atexit_header); | 485 | atexit(atexit_header); |
| 485 | 486 | ||
| 486 | if (target_pid == -1) { | 487 | if (forks) { |
| 487 | pid = fork(); | 488 | pid = fork(); |
| 488 | if (pid < 0) { | 489 | if (pid < 0) { |
| 489 | perror("failed to fork"); | 490 | perror("failed to fork"); |
| @@ -550,7 +551,7 @@ static int __cmd_record(int argc __used, const char **argv) | |||
| 550 | return err; | 551 | return err; |
| 551 | } | 552 | } |
| 552 | 553 | ||
| 553 | if (!system_wide) | 554 | if (!system_wide && profile_cpu == -1) |
| 554 | event__synthesize_thread(pid, process_synthesized_event, | 555 | event__synthesize_thread(pid, process_synthesized_event, |
| 555 | session); | 556 | session); |
| 556 | else | 557 | else |
| @@ -569,7 +570,8 @@ static int __cmd_record(int argc __used, const char **argv) | |||
| 569 | /* | 570 | /* |
| 570 | * Let the child rip | 571 | * Let the child rip |
| 571 | */ | 572 | */ |
| 572 | close(go_pipe[1]); | 573 | if (forks) |
| 574 | close(go_pipe[1]); | ||
| 573 | 575 | ||
| 574 | for (;;) { | 576 | for (;;) { |
| 575 | int hits = samples; | 577 | int hits = samples; |
| @@ -667,7 +669,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used) | |||
| 667 | 669 | ||
| 668 | argc = parse_options(argc, argv, options, record_usage, | 670 | argc = parse_options(argc, argv, options, record_usage, |
| 669 | PARSE_OPT_STOP_AT_NON_OPTION); | 671 | PARSE_OPT_STOP_AT_NON_OPTION); |
| 670 | if (!argc && target_pid == -1 && (!system_wide || profile_cpu == -1)) | 672 | if (!argc && target_pid == -1 && !system_wide && profile_cpu == -1) |
| 671 | usage_with_options(record_usage, options); | 673 | usage_with_options(record_usage, options); |
| 672 | 674 | ||
| 673 | symbol__init(); | 675 | symbol__init(); |
