diff options
author | Christopher Ferris <cferris@google.com> | 2014-05-05 23:37:12 +0000 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2014-05-05 23:37:12 +0000 |
commit | 8a1469083db18d5cd8f468d3165a7f3052a638c3 (patch) | |
tree | 68c723a73c3a1dd53bb9b5ad95a932b87107d3f9 /debuggerd | |
parent | 7cc73694fa8e4f4187453db55b88778f2903e923 (diff) | |
parent | 0fd6750ed3116d29cc49cc721fbbd38b3033aa0f (diff) | |
download | system_core-8a1469083db18d5cd8f468d3165a7f3052a638c3.zip system_core-8a1469083db18d5cd8f468d3165a7f3052a638c3.tar.gz system_core-8a1469083db18d5cd8f468d3165a7f3052a638c3.tar.bz2 |
am 0fd6750e: am fdadb420: am b52a48af: Merge "Log stack even if tombstone cannot be created."
* commit '0fd6750ed3116d29cc49cc721fbbd38b3033aa0f':
Log stack even if tombstone cannot be created.
Diffstat (limited to 'debuggerd')
-rwxr-xr-x | debuggerd/tombstone.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/debuggerd/tombstone.cpp b/debuggerd/tombstone.cpp index 10e2cc4..749752b 100755 --- a/debuggerd/tombstone.cpp +++ b/debuggerd/tombstone.cpp @@ -730,33 +730,40 @@ char* engrave_tombstone(pid_t pid, pid_t tid, int signal, int original_si_code, uintptr_t abort_msg_address, bool dump_sibling_threads, bool quiet, bool* detach_failed, int* total_sleep_time_usec) { if ((mkdir(TOMBSTONE_DIR, 0755) == -1) && (errno != EEXIST)) { - LOG("failed to create %s: %s\n", TOMBSTONE_DIR, strerror(errno)); + LOG("failed to create %s: %s\n", TOMBSTONE_DIR, strerror(errno)); } if (chown(TOMBSTONE_DIR, AID_SYSTEM, AID_SYSTEM) == -1) { - LOG("failed to change ownership of %s: %s\n", TOMBSTONE_DIR, strerror(errno)); + LOG("failed to change ownership of %s: %s\n", TOMBSTONE_DIR, strerror(errno)); } - if (selinux_android_restorecon(TOMBSTONE_DIR, 0) == -1) { - *detach_failed = false; - return NULL; + int fd = -1; + char* path = NULL; + if (selinux_android_restorecon(TOMBSTONE_DIR, 0) == 0) { + path = find_and_open_tombstone(&fd); + } else { + LOG("Failed to restore security context, not writing tombstone.\n"); } - int fd; - char* path = find_and_open_tombstone(&fd); - if (!path) { + if (fd < 0 && quiet) { + LOG("Skipping tombstone write, nothing to do.\n"); *detach_failed = false; return NULL; } log_t log; log.tfd = fd; - log.amfd = activity_manager_connect(); + // Preserve amfd since it can be modified through the calls below without + // being closed. + int amfd = activity_manager_connect(); + log.amfd = amfd; log.quiet = quiet; *detach_failed = dump_crash(&log, pid, tid, signal, original_si_code, abort_msg_address, dump_sibling_threads, total_sleep_time_usec); - close(log.amfd); + // Either of these file descriptors can be -1, any error is ignored. + close(amfd); close(fd); + return path; } |