Truncate trace output files.
To avoid creating trace files with garbage at the end.
Bug: 35588070
Test: atrace runs
Change-Id: I26ef4c652ca2e2dd8ff9d11d4f380b44791cb960
diff --git a/cmds/atrace/atrace.cpp b/cmds/atrace/atrace.cpp
index a6cde79..965a78e 100644
--- a/cmds/atrace/atrace.cpp
+++ b/cmds/atrace/atrace.cpp
@@ -1239,7 +1239,7 @@
fflush(stdout);
int outFd = STDOUT_FILENO;
if (g_outputFile) {
- outFd = open(g_outputFile, O_WRONLY | O_CREAT, 0644);
+ outFd = open(g_outputFile, O_WRONLY | O_CREAT | O_TRUNC, 0644);
}
if (outFd == -1) {
printf("Failed to open '%s', err=%d", g_outputFile, errno);