Skip to content

Commit 3835124

Browse files
committed
Merge branch 'ew/fd-cloexec-fix' into maint
Portability/fallback fix. * ew/fd-cloexec-fix: set FD_CLOEXEC properly when O_CLOEXEC is not supported
2 parents bae7e3f + 9fb9495 commit 3835124

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

sha1_file.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1684,14 +1684,14 @@ int git_open_cloexec(const char *name, int flags)
16841684
fd = open(name, flags | o_cloexec);
16851685
}
16861686

1687-
#if defined(F_GETFL) && defined(F_SETFL) && defined(FD_CLOEXEC)
1687+
#if defined(F_GETFD) && defined(F_SETFD) && defined(FD_CLOEXEC)
16881688
{
16891689
static int fd_cloexec = FD_CLOEXEC;
16901690

16911691
if (!o_cloexec && 0 <= fd && fd_cloexec) {
16921692
/* Opened w/o O_CLOEXEC? try with fcntl(2) to add it */
1693-
int flags = fcntl(fd, F_GETFL);
1694-
if (fcntl(fd, F_SETFL, flags | fd_cloexec))
1693+
int flags = fcntl(fd, F_GETFD);
1694+
if (fcntl(fd, F_SETFD, flags | fd_cloexec))
16951695
fd_cloexec = 0;
16961696
}
16971697
}

0 commit comments

Comments
 (0)