Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
set FD_CLOEXEC properly when O_CLOEXEC is not supported
author
Eric Wong
<e@80x24.org>
Sat, 15 Jul 2017 18:55:40 +0000
(18:55 +0000)
committer
Junio C Hamano
<gitster@pobox.com>
Mon, 17 Jul 2017 21:52:16 +0000
(14:52 -0700)
FD_CLOEXEC only applies to the file descriptor, so it needs to be
manipuluated via F_GETFD/F_SETFD. F_GETFL/F_SETFL are for file
description flags.
Verified via strace with o_cloexec set to zero.
Signed-off-by: Eric Wong <e@80x24.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sha1_file.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
1e3001a
)
diff --git
a/sha1_file.c
b/sha1_file.c
index 64e1a21fc61ed24a0b33c12578eab50546ec6270..5e3b6e411a5f7750d36ff18a4c27a199e3993685 100644
(file)
--- a/
sha1_file.c
+++ b/
sha1_file.c
@@
-1571,14
+1571,14
@@
int git_open_cloexec(const char *name, int flags)
fd = open(name, flags | o_cloexec);
}
fd = open(name, flags | o_cloexec);
}
-#if defined(F_GETF
L) && defined(F_SETFL
) && defined(FD_CLOEXEC)
+#if defined(F_GETF
D) && 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 */
{
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_GETF
L
);
- if (fcntl(fd, F_SETF
L
, flags | fd_cloexec))
+ int flags = fcntl(fd, F_GETF
D
);
+ if (fcntl(fd, F_SETF
D
, flags | fd_cloexec))
fd_cloexec = 0;
}
}
fd_cloexec = 0;
}
}