summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-07-20 16:30:00 -0700
committerJunio C Hamano <gitster@pobox.com>2017-07-20 16:30:00 -0700
commit2842e06352ecaffae0e1f57704526b6b324bd435 (patch)
treec0a05bc54535b2dda6517b0ff87b5d3034e21ad6
parente4efb39555582c5687df7a585f4cd9043dcd8ebc (diff)
parent9fb9495dae744098a6eb16f62b4876c87b2c773f (diff)
downloadgit-2842e06352ecaffae0e1f57704526b6b324bd435.tar.gz
Merge branch 'ew/fd-cloexec-fix'
Portability/fallback fix. * ew/fd-cloexec-fix: set FD_CLOEXEC properly when O_CLOEXEC is not supported
-rw-r--r--sha1_file.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sha1_file.c b/sha1_file.c
index fca165f13c..b60ae15f70 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -1684,14 +1684,14 @@ int git_open_cloexec(const char *name, int flags)
fd = open(name, flags | o_cloexec);
}
-#if defined(F_GETFL) && defined(F_SETFL) && defined(FD_CLOEXEC)
+#if defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
{
static int fd_cloexec = FD_CLOEXEC;
if (!o_cloexec && 0 <= fd && fd_cloexec) {
/* Opened w/o O_CLOEXEC? try with fcntl(2) to add it */
- int flags = fcntl(fd, F_GETFL);
- if (fcntl(fd, F_SETFL, flags | fd_cloexec))
+ int flags = fcntl(fd, F_GETFD);
+ if (fcntl(fd, F_SETFD, flags | fd_cloexec))
fd_cloexec = 0;
}
}