summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--winsup/cygwin/release/3.2.04
-rw-r--r--winsup/cygwin/syscalls.cc19
2 files changed, 23 insertions, 0 deletions
diff --git a/winsup/cygwin/release/3.2.0 b/winsup/cygwin/release/3.2.0
index f748a9bc8..d02d16863 100644
--- a/winsup/cygwin/release/3.2.0
+++ b/winsup/cygwin/release/3.2.0
@@ -19,6 +19,10 @@ What changed:
- A few FAQ updates.
+- Have tmpfile(3) make use of Win32 FILE_ATTRIBUTE_TEMPORARY via open(2)
+ flag O_TMPFILE.
+ Addresses: https://cygwin.com/pipermail/cygwin/2021-January/247304.html
+
Bug Fixes
---------
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index 52a020f07..d04b2d9b3 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -5225,3 +5225,22 @@ pipe2 (int filedes[2], int mode)
syscall_printf ("%R = pipe2([%d, %d], %y)", res, read, write, mode);
return res;
}
+
+extern "C" FILE *
+tmpfile (void)
+{
+ char *dir = getenv ("TMPDIR");
+ if (!dir)
+ dir = P_tmpdir;
+ int fd = open (dir, O_RDWR | O_BINARY | O_TMPFILE, S_IRUSR | S_IWUSR);
+ if (fd < 0)
+ return NULL;
+ FILE *fp = fdopen (fd, "wb+");
+ int e = errno;
+ if (!fp)
+ close (fd); // ..will remove tmp file
+ set_errno (e);
+ return fp;
+}
+
+EXPORT_ALIAS (tmpfile, tmpfile64)