summaryrefslogtreecommitdiff
path: root/cmds/dumpstate/dumpstate.cpp
diff options
context:
space:
mode:
author Felipe Leme <felipeal@google.com> 2016-03-29 13:29:11 -0700
committer Felipe Leme <felipeal@google.com> 2016-03-29 13:56:47 -0700
commitbaa85bd893665a48aee73d7ca7b73cd39b48f998 (patch)
treeda9667f142f84a2d4bafcf09ee34d5d3b77fe8a5 /cmds/dumpstate/dumpstate.cpp
parentabddf727041d2ea0e678442b2d7905afc8b33bd4 (diff)
Call _exit() instead of exit() on child failure.
As explained on man _exit: "The function _exit() terminates the calling process "immediately". Any open file descriptors belonging to the process are closed;" If exit() is called instead, the resulting zip file will be corrupted. BUG: 27900023 BUG: 27804637 Change-Id: I6591749603753d6016f350c629b7082cf6780ae2
Diffstat (limited to 'cmds/dumpstate/dumpstate.cpp')
-rw-r--r--cmds/dumpstate/dumpstate.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp
index bb485bfdee..30ddec3371 100644
--- a/cmds/dumpstate/dumpstate.cpp
+++ b/cmds/dumpstate/dumpstate.cpp
@@ -201,7 +201,8 @@ static void dump_systrace() {
execl("/system/bin/atrace", "/system/bin/atrace", "--async_dump", nullptr);
// execl should never return, but if it did, we need to exit.
MYLOGD("execl on '/system/bin/atrace --async_dump' failed: %s", strerror(errno));
- exit(EXIT_FAILURE);
+ // Must call _exit (instead of exit), otherwise it will corrupt the zip file.
+ _exit(EXIT_FAILURE);
} else {
close(pipefd[1]); // close the write end of the pipe in the parent
add_zip_entry_from_fd("systrace.txt", pipefd[0]); // write output to zip file