提交 fceda7fe 编写于 作者: D David Ahern 提交者: Arnaldo Carvalho de Melo

perf stat: Remove use of die/exit and handle errors

Allows perf to clean up properly on program termination.
Signed-off-by: NDavid Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1346005487-62961-5-git-send-email-dsahern@gmail.comSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 33d6aef5
...@@ -428,7 +428,7 @@ static int run_perf_stat(int argc __used, const char **argv) ...@@ -428,7 +428,7 @@ static int run_perf_stat(int argc __used, const char **argv)
if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) { if (forks && (pipe(child_ready_pipe) < 0 || pipe(go_pipe) < 0)) {
perror("failed to create pipes"); perror("failed to create pipes");
exit(1); return -1;
} }
if (forks) { if (forks) {
...@@ -510,7 +510,8 @@ static int run_perf_stat(int argc __used, const char **argv) ...@@ -510,7 +510,8 @@ static int run_perf_stat(int argc __used, const char **argv)
} }
if (child_pid != -1) if (child_pid != -1)
kill(child_pid, SIGTERM); kill(child_pid, SIGTERM);
die("Not all events could be opened.\n");
pr_err("Not all events could be opened.\n");
return -1; return -1;
} }
counter->supported = true; counter->supported = true;
...@@ -1189,7 +1190,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used) ...@@ -1189,7 +1190,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
output = fopen(output_name, mode); output = fopen(output_name, mode);
if (!output) { if (!output) {
perror("failed to create output file"); perror("failed to create output file");
exit(-1); return -1;
} }
clock_gettime(CLOCK_REALTIME, &tm); clock_gettime(CLOCK_REALTIME, &tm);
fprintf(output, "# started on %s\n", ctime(&tm.tv_sec)); fprintf(output, "# started on %s\n", ctime(&tm.tv_sec));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册