From: Junio C Hamano Date: Fri, 9 Sep 2016 04:35:56 +0000 (-0700) Subject: Merge branch 'bw/mingw-avoid-inheriting-fd-to-lockfile' into maint X-Git-Tag: v2.9.4~11 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/c0e8b3b444a701630c0793c195fd0e8162a95c2c?hp=-c 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 --- c0e8b3b444a701630c0793c195fd0e8162a95c2c diff --combined compat/mingw.h index 2cadb816ee,6090e83947..034fff9479 --- a/compat/mingw.h +++ b/compat/mingw.h @@@ -67,6 -67,10 +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 @@@ -417,6 -421,9 +421,6 @@@ int mingw_offset_1st_component(const ch #include #endif -void mingw_open_html(const char *path); -#define open_html mingw_open_html - /** * Converts UTF-8 encoded string to UTF-16LE. * @@@ -535,7 -542,7 +539,7 @@@ extern CRITICAL_SECTION pinfo_cs void mingw_startup(void); #define main(c,v) dummy_decl_mingw_main(void); \ static int mingw_main(c,v); \ -int main(int argc, char **argv) \ +int main(int argc, const char **argv) \ { \ mingw_startup(); \ return mingw_main(__argc, (void *)__argv); \ diff --combined git-compat-util.h index 1930444ef0,f1f98b50d7..9eab471264 --- a/git-compat-util.h +++ b/git-compat-util.h @@@ -650,6 -650,10 +650,10 @@@ void *gitmemmem(const void *haystack, s #define getpagesize() sysconf(_SC_PAGESIZE) #endif + #ifndef O_CLOEXEC + #define O_CLOEXEC 0 + #endif + #ifdef FREAD_READS_DIRECTORIES #ifdef fopen #undef fopen @@@ -1045,5 -1049,3 +1049,5 @@@ struct tm *git_gmtime_r(const time_t * #endif #endif + +extern int cmd_main(int, const char **);