From: Scott James Remnant <scott@canonical.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: Report: Threaded udevd
Date: Wed, 22 Oct 2008 16:22:30 +0000 [thread overview]
Message-ID: <1224692550.7588.11.camel@quest> (raw)
In-Reply-To: <48FF3458.6030909@tuffmail.co.uk>
[-- Attachment #1: Type: text/plain, Size: 847 bytes --]
On Wed, 2008-10-22 at 17:12 +0100, Alan Jenkins wrote:
> > The pipe2() syscall allows you to specify flags for the returned file
> > descriptors:
> >
> > pipe2 (&fds, O_CLOEXEC)
> >
>
> Ah! I see how it's supposed to be used now.
>
> pipe2 (&fds, O_CLOEXEC)
> if (fork() == 0) {
> dup2(&fds[WRITE_END], STDOUT_FILENO);
> /* insert call to fcntl to remove O_CLOEXEC */
> exec(program_name);
>
You don't need the call to fcntl. From the dup2(2) manpage:
The two descriptors do not share file descriptor flags (the close-on-
exec flag). The close-on-exec flag (FD_CLOEXEC; see fcntl(2)) for the
duplicate descriptor is off.
So after you dup2() the writing end to standard output, standard output
will not be closed on exec.
Scott
--
Scott James Remnant
scott@canonical.com
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
next prev parent reply other threads:[~2008-10-22 16:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-22 14:10 Report: Threaded udevd Alan Jenkins
2008-10-22 14:32 ` Scott James Remnant
2008-10-22 15:15 ` Marco d'Itri
2008-10-22 16:12 ` Alan Jenkins
2008-10-22 16:22 ` Scott James Remnant [this message]
2008-10-22 16:24 ` Greg KH
2008-10-22 17:02 ` Marco d'Itri
2008-10-22 17:11 ` Scott James Remnant
2008-10-22 17:14 ` Marco d'Itri
2008-10-23 16:25 ` Karl O. Pinc
2008-10-23 16:29 ` Marco d'Itri
2008-10-23 16:55 ` Karl O. Pinc
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=1224692550.7588.11.camel@quest \
--to=scott@canonical.com \
--cc=linux-hotplug@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;
as well as URLs for NNTP newsgroup(s).