create_temporary_file(): use _O_SHORT_LIVED on Windows
authorEric Biggers <ebiggers3@gmail.com>
Sun, 11 May 2014 05:23:27 +0000 (00:23 -0500)
committerEric Biggers <ebiggers3@gmail.com>
Sun, 11 May 2014 05:23:27 +0000 (00:23 -0500)
src/extract.c

index b1f62b1..f1fcd0f 100644 (file)
@@ -1171,6 +1171,7 @@ create_temporary_file(struct filedes *fd_ret, tchar **name_ret)
 {
        tchar *name;
        int raw_fd;
+       int open_flags;
 
 retry:
        name = ttempnam(NULL, T("wimlib"));
@@ -1179,7 +1180,11 @@ retry:
                return WIMLIB_ERR_NOMEM;
        }
 
-       raw_fd = topen(name, O_WRONLY | O_CREAT | O_EXCL | O_BINARY, 0600);
+       open_flags = O_WRONLY | O_CREAT | O_EXCL | O_BINARY;
+#ifdef __WIN32__
+       open_flags |= _O_SHORT_LIVED;
+#endif
+       raw_fd = topen(name, open_flags, 0600);
 
        if (raw_fd < 0) {
                if (errno == EEXIST) {