diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-12-06 12:13:38 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2010-12-06 12:13:38 -0500 |
commit | 18483b81ee7e70ee68d4b18be618be5cfcc0b290 (patch) | |
tree | c553f0170c99e2c421f141328bf21e3a310ac174 | |
parent | 60e677373be9c0bf7c9a22937601d5a40e51c042 (diff) |
perf record: Fix eternal wait for stillborn child
When execvp fails to find the specified command on the path we won't get
SIGCHLD, so send a SIGUSR1 and exit right away.
Current situation would require a SIGINT performed by the user and would
produce meaningless summary.
Now:
[acme@emilia linux]$ ./foo
-bash: ./foo: No such file or directory
[acme@emilia linux]$ perf record ./foo
./foo: No such file or directory
[acme@emilia linux]$
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
LKML-Reference: <new-submission>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-record.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index e2c2de201eec..564491fa18b2 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -197,7 +197,7 @@ static void sig_atexit(void) | |||
197 | if (child_pid > 0) | 197 | if (child_pid > 0) |
198 | kill(child_pid, SIGTERM); | 198 | kill(child_pid, SIGTERM); |
199 | 199 | ||
200 | if (signr == -1) | 200 | if (signr == -1 || signr == SIGUSR1) |
201 | return; | 201 | return; |
202 | 202 | ||
203 | signal(signr, SIG_DFL); | 203 | signal(signr, SIG_DFL); |
@@ -515,6 +515,7 @@ static int __cmd_record(int argc, const char **argv) | |||
515 | atexit(sig_atexit); | 515 | atexit(sig_atexit); |
516 | signal(SIGCHLD, sig_handler); | 516 | signal(SIGCHLD, sig_handler); |
517 | signal(SIGINT, sig_handler); | 517 | signal(SIGINT, sig_handler); |
518 | signal(SIGUSR1, sig_handler); | ||
518 | 519 | ||
519 | if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) { | 520 | if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) { |
520 | perror("failed to create pipes"); | 521 | perror("failed to create pipes"); |
@@ -606,6 +607,7 @@ static int __cmd_record(int argc, const char **argv) | |||
606 | execvp(argv[0], (char **)argv); | 607 | execvp(argv[0], (char **)argv); |
607 | 608 | ||
608 | perror(argv[0]); | 609 | perror(argv[0]); |
610 | kill(getppid(), SIGUSR1); | ||
609 | exit(-1); | 611 | exit(-1); |
610 | } | 612 | } |
611 | 613 | ||
@@ -762,7 +764,7 @@ static int __cmd_record(int argc, const char **argv) | |||
762 | } | 764 | } |
763 | } | 765 | } |
764 | 766 | ||
765 | if (quiet) | 767 | if (quiet || signr == SIGUSR1) |
766 | return 0; | 768 | return 0; |
767 | 769 | ||
768 | fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking); | 770 | fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking); |