From 28e69f75088684b41d30b051799d7687d33f2205 Mon Sep 17 00:00:00 2001 From: Yabin Cui Date: Wed, 25 Mar 2015 12:36:18 -0700 Subject: [PATCH] Add O_APPEND flag for __libc_write_stderr. For DeathTests, we are testing the output of stderr to check if it is the death we are expecting. To collect the output, Gtest redirects stderr to a temporary file. But in __libc_write_stderr in libc_logging.cpp, we are writing to stderr without a O_APPEND flag, so a new message will overwrite a previous message. The above situation makes almost all the DeathTests fail on host. Because the expected message are always overwritten in host DeathTests. So I add O_APPEND flag in __libc_write_stderr, which makes all host DeathTests pass. Change-Id: Ic2f6044fdb181eebe132a6f170b57db43c5c3289 --- libc/bionic/libc_logging.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libc/bionic/libc_logging.cpp b/libc/bionic/libc_logging.cpp index 2eb9d68f8..7ad21c4cd 100644 --- a/libc/bionic/libc_logging.cpp +++ b/libc/bionic/libc_logging.cpp @@ -427,7 +427,7 @@ int __libc_format_fd(int fd, const char* format, ...) { } static int __libc_write_stderr(const char* tag, const char* msg) { - int fd = TEMP_FAILURE_RETRY(open("/dev/stderr", O_CLOEXEC | O_WRONLY)); + int fd = TEMP_FAILURE_RETRY(open("/dev/stderr", O_CLOEXEC | O_WRONLY | O_APPEND)); if (fd == -1) { return -1; }