Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 234360
b: refs/heads/master
c: d7065ad
h: refs/heads/master
v: v3
  • Loading branch information
Franck Bui-Huu authored and Arnaldo Carvalho de Melo committed Jan 24, 2011
1 parent 56bf440 commit 50b8e95
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e80711ca8512c8586da0c3e18e2f1caf73c88731
refs/heads/master: d7065adb9b4f3384c2615f0a3dbdb6c3aae1eb18
32 changes: 20 additions & 12 deletions trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static unsigned int user_freq = UINT_MAX;
static int freq = 1000;
static int output;
static int pipe_output = 0;
static const char *output_name = "perf.data";
static const char *output_name = NULL;
static int group = 0;
static int realtime_prio = 0;
static bool nodelay = false;
Expand Down Expand Up @@ -497,18 +497,26 @@ static int __cmd_record(int argc, const char **argv)
exit(-1);
}

if (!strcmp(output_name, "-"))
pipe_output = 1;
else if (!stat(output_name, &st) && st.st_size) {
if (write_mode == WRITE_FORCE) {
char oldname[PATH_MAX];
snprintf(oldname, sizeof(oldname), "%s.old",
output_name);
unlink(oldname);
rename(output_name, oldname);
if (!output_name) {
if (!fstat(STDOUT_FILENO, &st) && S_ISFIFO(st.st_mode))
pipe_output = 1;
else
output_name = "perf.data";
}
if (output_name) {
if (!strcmp(output_name, "-"))
pipe_output = 1;
else if (!stat(output_name, &st) && st.st_size) {
if (write_mode == WRITE_FORCE) {
char oldname[PATH_MAX];
snprintf(oldname, sizeof(oldname), "%s.old",
output_name);
unlink(oldname);
rename(output_name, oldname);
}
} else if (write_mode == WRITE_APPEND) {
write_mode = WRITE_FORCE;
}
} else if (write_mode == WRITE_APPEND) {
write_mode = WRITE_FORCE;
}

flags = O_CREAT|O_RDWR;
Expand Down

0 comments on commit 50b8e95

Please sign in to comment.