Re: [PATCH] perf record: handle death by SIGTERM

From: Stephane Eranian
Date: Mon May 06 2013 - 18:40:55 EST


This is a good fix. I have run into this infinite loop in perf report
many times.
Thanks David.

On Mon, May 6, 2013 at 8:24 PM, David Ahern <dsahern@xxxxxxxxx> wrote:
> perf data files cannot be processed until the header file is update
> which is done via an on_exit handler. If perf is killed due to a SIGTERM
> it does not run the on_exit hooks leaving the perf.data file in a
> random state which perf-report will happily spin on trying to read. As
> noted by Mike an easy reproducer is:
> perf record -a -g & sleep 1; killall perf
>
> Fix by catching SIGTERM like it does SIGINT. Also need to remove the
> kill which was added via commit f7b7c26e.
>
> Signed-off-by: David Ahern <dsahern@xxxxxxxxx>
> Cc: Mike Galbraith <efault@xxxxxx>
> Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxxxxxxxxxx>
> Cc: Ingo Molnar <mingo@xxxxxxxxxx>
> Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
> Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Cc: Stephane Eranian <eranian@xxxxxxxxxx>
> ---
> tools/perf/builtin-record.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
> index cdf58ec..fff985c 100644
> --- a/tools/perf/builtin-record.c
> +++ b/tools/perf/builtin-record.c
> @@ -198,7 +198,6 @@ static void perf_record__sig_exit(int exit_status __maybe_unused, void *arg)
> return;
>
> signal(signr, SIG_DFL);
> - kill(getpid(), signr);
> }
>
> static bool perf_evlist__equal(struct perf_evlist *evlist,
> @@ -404,6 +403,7 @@ static int __cmd_record(struct perf_record *rec, int argc, const char **argv)
> signal(SIGCHLD, sig_handler);
> signal(SIGINT, sig_handler);
> signal(SIGUSR1, sig_handler);
> + signal(SIGTERM, sig_handler);
>
> if (!output_name) {
> if (!fstat(STDOUT_FILENO, &st) && S_ISFIFO(st.st_mode))
> --
> 1.7.10.1
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/