Johannes Schindelin <johannes.schindelin@xxxxxx> wrote: > As Eric Wong pointed out, we need to be careful to handle the case where > the Linux headers used to compile Git support O_CLOEXEC but the Linux > kernel used to run Git does not: it returns an EINVAL. > +++ b/git-compat-util.h > @@ -667,6 +667,10 @@ void *gitmemmem(const void *haystack, size_t haystacklen, > #define getpagesize() sysconf(_SC_PAGESIZE) > #endif > > +#ifndef O_CLOEXEC > +#define O_CLOEXEC 0 > +#endif > +++ b/tempfile.c > @@ -120,7 +120,12 @@ int create_tempfile(struct tempfile *tempfile, const char *path) > prepare_tempfile_object(tempfile); > > strbuf_add_absolute_path(&tempfile->filename, path); > - tempfile->fd = open(tempfile->filename.buf, O_RDWR | O_CREAT | O_EXCL, 0666); > + tempfile->fd = open(tempfile->filename.buf, > + O_RDWR | O_CREAT | O_EXCL | O_CLOEXEC, 0666); > + if (O_CLOEXEC && tempfile->fd < 0 && errno == EINVAL) > + /* Try again w/o O_CLOEXEC: the kernel might not support it */ > + tempfile->fd = open(tempfile->filename.buf, > + O_RDWR | O_CREAT | O_EXCL, 0666); > if (tempfile->fd < 0) { > strbuf_reset(&tempfile->filename); > return -1; Looks good to me from a Linux standpoint. Thanks. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html