From: Jamie Lokier <jamie@shareable.org>
To: Ulrich Drepper <drepper@redhat.com>
Cc: "linux-kern >> Linux Kernel" <linux-kernel@vger.kernel.org>
Subject: Re: For the almost 4-year anniversary: O_CLOEXEC again
Date: Mon, 29 Mar 2004 14:18:19 +0100 [thread overview]
Message-ID: <20040329131819.GF4984@mail.shareable.org> (raw)
In-Reply-To: <40677D1B.9060801@redhat.com>
Ulrich Drepper wrote:
> It cannot be done through a per-thread switch which decides whether
> newly allocated descriptors are CLOEXEC until further notice since
> open() is a signal-safe interface. The signal handler code might
> not be aware of this mode and create descriptors which are not
> inherited.
Since O_CLOEXEC is non-portable, why not implement the per-thread
switch?
Signal handlers that call open() will have to be aware of it, but
that's ok: an application will only set the switch if it knows what
that implies.
For POSIX compatibility the switch should be off initially, and only
turned on at the application's request.
Portable code which assumes POSIX interfaces has to have another way
to work around the close-on-exec problem anyway.
Overall I like the O_CLOEXEC flag. It really should have always been
an O_* flag, and F_SETFL should be able to change it.
The only problem is there are so many other ways to get file
descriptors which it doesn't help with. Most especially sockets,
which are heavily used in the kinds of programs which use threads and
and forking.
Btw, is open() the only signal-safe interface where this matters?
Perhaps a per-thread flag could be used for all the _other_ file
descriptor generating interfaces, but not for open() where only
O_CLOEXEC would work?
-- Jamie
next prev parent reply other threads:[~2004-03-29 13:21 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-29 1:34 For the almost 4-year anniversary: O_CLOEXEC again Ulrich Drepper
2004-03-29 3:14 ` Davide Libenzi
2004-03-29 4:23 ` dean gaudet
2004-03-29 13:18 ` Jamie Lokier [this message]
2004-03-29 18:59 ` Ulrich Drepper
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=20040329131819.GF4984@mail.shareable.org \
--to=jamie@shareable.org \
--cc=drepper@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox