From: Pierre Habouzit <pierre.habouzit@intersec.com>
To: Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: linux-kernel@vger.kernel.org,
Pierre Habouzit <madcoder@debian.org>,
Pierre Habouzit <pierre.habouzit@intersec.com>
Subject: [PATCH 2/2] perf-record: improve -A UI for empty or non-existent perf.data
Date: Fri, 7 Aug 2009 14:16:01 +0200 [thread overview]
Message-ID: <1249647361-11582-3-git-send-email-pierre.habouzit@intersec.com> (raw)
In-Reply-To: <1249647361-11582-2-git-send-email-pierre.habouzit@intersec.com>
From: Pierre Habouzit <madcoder@debian.org>
1. Ignore the -A argument if there is no perf.data file
2. Treat an empty file like a non existent file.
Else, perf will try to read the perf.data header, and fail with an error.
Treating an empty file like a non-existent file makes sense, since an
interupted (as in SIGKILLed) perf could leave such files around, and you
don't want to annoy the user with errors for files with no data in it.
Signed-off-by: Pierre Habouzit <pierre.habouzit@intersec.com>
---
tools/perf/builtin-record.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 6da0992..afbfb9d 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -524,10 +524,14 @@ static int __cmd_record(int argc, const char **argv)
signal(SIGCHLD, sig_handler);
signal(SIGINT, sig_handler);
- if (!stat(output_name, &st) && !force && !append_file) {
- fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n",
- output_name);
- exit(-1);
+ if (!stat(output_name, &st) && st.st_size) {
+ if (!force && !append_file) {
+ fprintf(stderr, "Error, output file %s exists, use -A to append or -f to overwrite.\n",
+ output_name);
+ exit(-1);
+ }
+ } else {
+ append_file = 0;
}
flags = O_CREAT|O_RDWR;
--
1.6.4.rc2.183.g9085a
next prev parent reply other threads:[~2009-08-07 12:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-07 12:15 perf-record fix and UI improvement Pierre Habouzit
2009-08-07 12:16 ` [PATCH 1/2] perf util: do_read should fail on EOF instead of busy-looping Pierre Habouzit
2009-08-07 12:16 ` Pierre Habouzit [this message]
2009-08-07 15:10 ` [tip:perfcounters/urgent] perf record: Fix the -A UI for empty or non-existent perf.data tip-bot for Pierre Habouzit
2009-08-07 15:09 ` [tip:perfcounters/urgent] perf util: Fix do_read() to fail on EOF instead of busy-looping tip-bot for Pierre Habouzit
2009-08-07 12:28 ` perf-record fix and UI improvement Pierre Habouzit
2009-08-07 13:01 ` Peter Zijlstra
2009-08-07 13:59 ` Pierre Habouzit
2009-08-07 15:09 ` Ingo Molnar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1249647361-11582-3-git-send-email-pierre.habouzit@intersec.com \
--to=pierre.habouzit@intersec.com \
--cc=a.p.zijlstra@chello.nl \
--cc=linux-kernel@vger.kernel.org \
--cc=madcoder@debian.org \
--cc=mingo@elte.hu \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®