Re: [PATCH v3 2/3] sha1_file: open window into packfiles with O_CLOEXEC
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 28, 2016, 17:47 UTC
- Message-ID
- <xmqq60oc1i3a.fsf@gitster.mtv.corp.google.com>
- In-Reply-To
- <CA+55aFwUEzfvWVSZfhBi85QaKWSo-gVMOk1BJFrR0ZsdCRHRsg@mail.gmail.com>
Linus Torvalds <torvalds@linux-foundation.org> writes:
Show 10 quoted lines
> On Fri, Oct 28, 2016 at 9:48 AM, Junio C Hamano <gitster@pobox.com> wrote: >> >> Setting FD_CLOEXEC with fcntl(2) may be racy, but in what way >> it is broken to open(2) with O_CLOEXEC? > > Apparently windows doesn't even support it, at least not mingw. So > you'll have to have some supprt for just explicitly closing things at > execve anyway. And if you do that for windows, then what's the point > of using O_CLOEXEC on Linux, and having two totally different paths > that will just mean maintenance headache.
Ah, that's where your reaction comes from. If I understood Dscho correctly, what he said was that I cannot set FD_CLOEXEC via fcntl() emulation they have. It wasn't an objection to O_CLOEXEC. In fact, since 05d1ed6148 ("mingw: ensure temporary file handles are not inherited by child processes", 2016-08-22), we have been relying on open(2) with O_CLOEXEC even on Windows (by emulating it with O_NOINHERIT, which Windows has) on some codepaths.