lkml.org 
[lkml]   [2012]   [Apr]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] perf stat: fix output selection introduced in 56f3bae7
Date
56f3bae7 makes perf require either --output or --log-fd. Without them
perf exited after erroneously trying to open stdout (file descriptor 0
by default) for writing.

Signed-off-by: Łuaksz Stelmach <l.stelmach@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
tools/perf/builtin-stat.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index c941bb6..c0f8129 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -196,7 +196,7 @@ static bool csv_output = false;
static bool group = false;
static const char *output_name = NULL;
static FILE *output = NULL;
-static int output_fd;
+static int output_fd = -1;

static volatile int done = 0;

@@ -1146,7 +1146,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
if (output_name && strcmp(output_name, "-"))
output = NULL;

- if (output_name && output_fd) {
+ if (output_name && output_fd >= 0) {
fprintf(stderr, "cannot use both --output and --log-fd\n");
usage_with_options(stat_usage, options);
}
@@ -1161,7 +1161,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
}
clock_gettime(CLOCK_REALTIME, &tm);
fprintf(output, "# started on %s\n", ctime(&tm.tv_sec));
- } else if (output_fd != 2) {
+ } else if (output_fd >= 0) {
mode = append_file ? "a" : "w";
output = fdopen(output_fd, mode);
if (!output) {
--
1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2012-04-19 10:17    [W:0.046 / U:0.120 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site