summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorKarel Zak2019-04-16 13:42:34 +0200
committerKarel Zak2019-04-16 13:42:34 +0200
commit31c66833cb8e3aad8af0eea4a1744e9e14f657b9 (patch)
tree34325c789284fd56291060001cda0f9791a2dc60 /include
parentchcpu: fix memory leak (diff)
downloadkernel-qcow2-util-linux-31c66833cb8e3aad8af0eea4a1744e9e14f657b9.tar.gz
kernel-qcow2-util-linux-31c66833cb8e3aad8af0eea4a1744e9e14f657b9.tar.xz
kernel-qcow2-util-linux-31c66833cb8e3aad8af0eea4a1744e9e14f657b9.zip
include/closestream: add close_stdout_atexit()
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>
Diffstat (limited to 'include')
-rw-r--r--include/closestream.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/include/closestream.h b/include/closestream.h
index b3b257c94..0ce34fe52 100644
--- a/include/closestream.h
+++ b/include/closestream.h
@@ -51,6 +51,17 @@ close_stdout(void)
_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__)))