From: Eric Wong <e@80x24.org>
To: Johannes Schindelin <johannes.schindelin@gmx.de>
Cc: git@vger.kernel.org, Ben Wijen <ben@wijen.net>,
Junio C Hamano <gitster@pobox.com>,
Lars Schneider <larsxschneider@gmail.com>,
Eric Sunshine <sunshine@sunshineco.com>
Subject: Re: [PATCH v3 2/2] mingw: ensure temporary file handles are not inherited by child processes
Date: Mon, 22 Aug 2016 17:58:05 +0000 [thread overview]
Message-ID: <20160822175805.GA10495@starla> (raw)
In-Reply-To: <b31d13befa305e46bd51f8c168f42071ce2dc663.1471869985.git.johannes.schindelin@gmx.de>
Johannes Schindelin <johannes.schindelin@gmx.de> 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.
prev parent reply other threads:[~2016-08-22 17:58 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-17 12:40 [PATCH 0/2] Do not lock temporary files via child processes on Windows Johannes Schindelin
2016-08-17 12:40 ` [PATCH 1/2] t6026-merge-attr: child processes must not inherit index.lock handles Johannes Schindelin
2016-08-17 17:55 ` Junio C Hamano
2016-08-17 12:41 ` [PATCH 2/2] mingw: ensure temporary file handles are not inherited by child processes Johannes Schindelin
2016-08-17 12:48 ` Eric Sunshine
2016-08-18 14:42 ` Johannes Schindelin
2016-08-17 13:14 ` Lars Schneider
2016-08-17 18:22 ` Junio C Hamano
2016-08-18 14:50 ` Johannes Schindelin
2016-08-18 17:35 ` Eric Wong
2016-08-18 21:53 ` Junio C Hamano
2016-08-18 22:48 ` Eric Wong
2016-08-19 15:57 ` Junio C Hamano
2016-08-22 12:47 ` Johannes Schindelin
2016-08-18 14:51 ` [PATCH v2 0/2] Do not lock temporary files via child processes on Windows Johannes Schindelin
2016-08-18 14:51 ` [PATCH v2 1/2] t6026-merge-attr: child processes must not inherit index.lock handles Johannes Schindelin
2016-08-18 14:51 ` [PATCH v2 2/2] mingw: ensure temporary file handles are not inherited by child processes Johannes Schindelin
2016-08-22 12:47 ` [PATCH v3 0/2] Do not lock temporary files via child processes on Windows Johannes Schindelin
2016-08-22 12:47 ` [PATCH v3 1/2] t6026-merge-attr: child processes must not inherit index.lock handles Johannes Schindelin
2016-08-22 12:47 ` [PATCH v3 2/2] mingw: ensure temporary file handles are not inherited by child processes Johannes Schindelin
2016-08-22 17:58 ` Eric Wong [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160822175805.GA10495@starla \
--to=e@80x24.org \
--cc=ben@wijen.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=johannes.schindelin@gmx.de \
--cc=larsxschneider@gmail.com \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.