summaryrefslogtreecommitdiff
path: root/lockfile.h
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2016-08-25 13:55:07 -0700
committerJunio C Hamano <gitster@pobox.com>2016-08-25 13:55:07 -0700
commit3dc01702dfbdbfc7116a21c4a5b32f088029bacf (patch)
tree1632731cd6f30e9a86dda0de15253f399d3e0f11 /lockfile.h
parenta8998453bebd7a4d620c78773917f1189ff4e672 (diff)
parent05d1ed6148305d299693000856e4971e9f642662 (diff)
Merge branch 'bw/mingw-avoid-inheriting-fd-to-lockfile'
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 'lockfile.h')
-rw-r--r--lockfile.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/lockfile.h b/lockfile.h
index 3d301937b0..d26ad27b2b 100644
--- a/lockfile.h
+++ b/lockfile.h
@@ -55,6 +55,10 @@
* * calling `fdopen_lock_file()` to get a `FILE` pointer for the
* open file and writing to the file using stdio.
*
+ * Note that the file descriptor returned by hold_lock_file_for_update()
+ * is marked O_CLOEXEC, so the new contents must be written by the
+ * current process, not a spawned one.
+ *
* When finished writing, the caller can:
*
* * Close the file descriptor and rename the lockfile to its final