summaryrefslogtreecommitdiff
path: root/compat
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-09-09 04:35:56 (GMT)
committerJunio C Hamano <gitster@pobox.com>2016-09-09 04:35:56 (GMT)
commitc0e8b3b444a701630c0793c195fd0e8162a95c2c (patch)
tree7f6e853f4bfe370ae3835c0bc210ed1b0c63bed2 /compat
parent15a27298fc5b2d8011f0087ab6f03996215971ef (diff)
parent05d1ed6148305d299693000856e4971e9f642662 (diff)
downloadgit-c0e8b3b444a701630c0793c195fd0e8162a95c2c.zip
git-c0e8b3b444a701630c0793c195fd0e8162a95c2c.tar.gz
git-c0e8b3b444a701630c0793c195fd0e8162a95c2c.tar.bz2
Merge branch 'bw/mingw-avoid-inheriting-fd-to-lockfile' into maint
The tempfile (hence its user lockfile) API lets the caller to open a file descriptor to a temporary file, write into it and then finalize it by first closing the filehandle and then either removing or renaming the temporary file. When the process spawns a subprocess after obtaining the file descriptor, and if the subprocess has not exited when the attempt to remove or rename is made, the last step fails on Windows, because the subprocess has the file descriptor still open. Open tempfile with O_CLOEXEC flag to avoid this (on Windows, this is mapped to O_NOINHERIT). * bw/mingw-avoid-inheriting-fd-to-lockfile: mingw: ensure temporary file handles are not inherited by child processes t6026-merge-attr: child processes must not inherit index.lock handles
Diffstat (limited to 'compat')
-rw-r--r--compat/mingw.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/compat/mingw.h b/compat/mingw.h
index 2cadb81..034fff9 100644
--- a/compat/mingw.h
+++ b/compat/mingw.h
@@ -67,6 +67,10 @@ typedef int pid_t;
#define F_SETFD 2
#define FD_CLOEXEC 0x1
+#if !defined O_CLOEXEC && defined O_NOINHERIT
+#define O_CLOEXEC O_NOINHERIT
+#endif
+
#ifndef EAFNOSUPPORT
#define EAFNOSUPPORT WSAEAFNOSUPPORT
#endif