Commit c1166d4f653bf6d17ad8c265cf5e8da84e2e76dc

Mickaël Salaün 2014-05-12T19:44:08

closures: Check for mkostemp(3)

diff --git a/configure.ac b/configure.ac
index d3b8b99..d7b6e40 100644
--- a/configure.ac
+++ b/configure.ac
@@ -64,7 +64,7 @@ EOF
 AM_MAINTAINER_MODE
 
 AC_CHECK_HEADERS(sys/mman.h)
-AC_CHECK_FUNCS(mmap)
+AC_CHECK_FUNCS([mmap mkostemp])
 AC_FUNC_MMAP_BLACKLIST
 
 dnl The -no-testsuite modules omit the test subdir.
diff --git a/src/closures.c b/src/closures.c
index 9799ce6..78818d9 100644
--- a/src/closures.c
+++ b/src/closures.c
@@ -267,7 +267,13 @@ static size_t execsize = 0;
 static int
 open_temp_exec_file_name (char *name, int flags)
 {
-  int fd = mkostemp (name, flags);
+  int fd;
+
+#ifdef HAVE_MKOSTEMP
+  fd = mkostemp (name, flags);
+#else
+  fd = mkstemp (name);
+#endif
 
   if (fd != -1)
     unlink (name);