summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--clang/tools/c-arcmt-test/c-arcmt-test.c12
-rw-r--r--clang/tools/c-index-test/c-index-test.c12
2 files changed, 18 insertions, 6 deletions
diff --git a/clang/tools/c-arcmt-test/c-arcmt-test.c b/clang/tools/c-arcmt-test/c-arcmt-test.c
index 56a4132dba3..60faed03dc5 100644
--- a/clang/tools/c-arcmt-test/c-arcmt-test.c
+++ b/clang/tools/c-arcmt-test/c-arcmt-test.c
@@ -97,14 +97,20 @@ typedef struct thread_info {
void thread_runner(void *client_data_v) {
thread_info *client_data = client_data_v;
client_data->result = carcmttest_main(client_data->argc, client_data->argv);
-#ifdef __CYGWIN__
- fflush(stdout); /* stdout is not flushed on Cygwin. */
-#endif
+}
+
+static void flush_atexit(void) {
+ // stdout, and surprisingly even stderr, are not always flushed on process
+ // and thread exit, particularly when the system is under heavy load.
+ fflush(stdout);
+ fflush(stderr);
}
int main(int argc, const char **argv) {
thread_info client_data;
+ atexit(flush_atexit);
+
#if defined(_WIN32)
if (getenv("LIBCLANG_LOGGING") == NULL)
putenv("LIBCLANG_LOGGING=1");
diff --git a/clang/tools/c-index-test/c-index-test.c b/clang/tools/c-index-test/c-index-test.c
index 1d5cb1434c6..576f3c4a589 100644
--- a/clang/tools/c-index-test/c-index-test.c
+++ b/clang/tools/c-index-test/c-index-test.c
@@ -4116,14 +4116,20 @@ typedef struct thread_info {
void thread_runner(void *client_data_v) {
thread_info *client_data = client_data_v;
client_data->result = cindextest_main(client_data->argc, client_data->argv);
-#ifdef __CYGWIN__
- fflush(stdout); /* stdout is not flushed on Cygwin. */
-#endif
+}
+
+static void flush_atexit(void) {
+ // stdout, and surprisingly even stderr, are not always flushed on process
+ // and thread exit, particularly when the system is under heavy load.
+ fflush(stdout);
+ fflush(stderr);
}
int main(int argc, const char **argv) {
thread_info client_data;
+ atexit(flush_atexit);
+
#ifdef CLANG_HAVE_LIBXML
LIBXML_TEST_VERSION
#endif
OpenPOWER on IntegriCloud