It seems better to have a way to control when atexit(close_stdout()) is
used, because close stdout means that for example ASAN (or another
into binary integrated tool) is not able to print the final summary.
Signed-off-by: Karel Zak <kzak@redhat.com>
AS_IF([test "x$enable_asan" = xyes], [
UL_WARN_ADD([-fsanitize=address])
ASAN_LDFLAGS="-fsanitize=address"
+],[
+ AC_DEFINE([USE_CLOSE_ATEXIT], [1], [close stdout at exit])
])
AC_SUBST([ASAN_LDFLAGS])
_exit(CLOSE_EXIT_CODE);
}
+static inline void
+close_stdout_atexit(void)
+{
+ /*
+ * Note that close stdout at exit disables ASAN to report memory leaks
+ */
+#ifdef USE_CLOSE_ATEXIT
+ atexit(close_stdout);
+#endif
+}
+
#ifndef HAVE_FSYNC
static inline int
fsync(int fd __attribute__((__unused__)))