Skip to content

Commit

Permalink
perf record: Fix eternal wait for stillborn child
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Arnaldo Carvalho de Melo committed Dec 6, 2010
1 parent 60e6773 commit 18483b8
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ static void sig_atexit(void)
if (child_pid > 0)
kill(child_pid, SIGTERM);

if (signr == -1)
if (signr == -1 || signr == SIGUSR1)
return;

signal(signr, SIG_DFL);
Expand Down Expand Up @@ -515,6 +515,7 @@ static int __cmd_record(int argc, const char **argv)
atexit(sig_atexit);
signal(SIGCHLD, sig_handler);
signal(SIGINT, sig_handler);
signal(SIGUSR1, sig_handler);

if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) {
perror("failed to create pipes");
Expand Down Expand Up @@ -606,6 +607,7 @@ static int __cmd_record(int argc, const char **argv)
execvp(argv[0], (char **)argv);

perror(argv[0]);
kill(getppid(), SIGUSR1);
exit(-1);
}

Expand Down Expand Up @@ -762,7 +764,7 @@ static int __cmd_record(int argc, const char **argv)
}
}

if (quiet)
if (quiet || signr == SIGUSR1)
return 0;

fprintf(stderr, "[ perf record: Woken up %ld times to write data ]\n", waking);
Expand Down

0 comments on commit 18483b8

Please sign in to comment.