OSDN Git Service

Truncate trace output files.
authorMartijn Coenen <maco@google.com>
Wed, 22 Feb 2017 08:25:31 +0000 (09:25 +0100)
committerMartijn Coenen <maco@google.com>
Wed, 22 Feb 2017 08:25:31 +0000 (09:25 +0100)
To avoid creating trace files with garbage at the end.

Bug: 35588070
Test: atrace runs
Change-Id: I26ef4c652ca2e2dd8ff9d11d4f380b44791cb960

cmds/atrace/atrace.cpp

index a6cde79..965a78e 100644 (file)
@@ -1239,7 +1239,7 @@ int main(int argc, char **argv)
             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);