summaryrefslogtreecommitdiff
path: root/configure.ac
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@colm.net>2020-12-08 00:12:36 +0000
committerAdrian Thurston <thurston@colm.net>2020-12-08 00:12:36 +0000
commitfe0e546c65accd2e9ca0fa5410fd88a9b64b36a4 (patch)
tree19335864620e514d73d62b38c76c773c1bf8e227 /configure.ac
parent5f310c57af176d7a9a113cbe7fc5b0ff4e4b75f5 (diff)
downloadcolm-fe0e546c65accd2e9ca0fa5410fd88a9b64b36a4.tar.gz
use fopencookie to avoid leaking FILE structs
If we use fdopen for stdin/out/err we cannot close it to free the file struct without also closing the file descriptor. If fopencookie is available, use that to wrap the file descriptor, but allow closing without closing the fd. This is useful when embedding in long running programs.
Diffstat (limited to 'configure.ac')
-rw-r--r--configure.ac9
1 files changed, 9 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 298da146..11b5d00a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -406,6 +406,15 @@ AC_SUBST(EXTERNAL_COLM)
AC_SUBST(EXTERNAL_INC)
AC_SUBST(EXTERNAL_LIBS)
+dnl Check for fopencookie. If available, we will use to avoid leaking FILE structs.
+dnl The result of an fdopen cannot be closed without also closing the fd, so we
+dnl make our own FILE type.
+AC_CHECK_FUNC(fopencookie,
+ [AC_DEFINE([HAVE_FOPENCOOKIE], [1], [have fopencookie])],
+ []
+)
+
+
dnl
dnl Wrap up.
dnl