From: Kevin Wolf <kwolf@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] Don't leak file descriptors
Date: Tue, 17 Nov 2009 10:00:57 +0100 [thread overview]
Message-ID: <4B026649.8040603@redhat.com> (raw)
In-Reply-To: <4B01DF9B.6010407@codemonkey.ws>
Am 17.11.2009 00:26, schrieb Anthony Liguori:
> Kevin Wolf wrote:
>> We're leaking file descriptors to child processes. Set FD_CLOEXEC on file
>> descriptors that don't need to be passed to children to stop this misbehaviour.
>>
>> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>>
>
> pid = fork();
> if (pid == 0) {
> int open_max = sysconf(_SC_OPEN_MAX), i;
>
> for (i = 0; i < open_max; i++) {
> if (i != STDIN_FILENO &&
> i != STDOUT_FILENO &&
> i != STDERR_FILENO &&
> i != fd) {
> close(i);
> }
>
> Handles this in a less invasive way. I think the only problem we have
> today is that we use popen() for exec: migration. The solution to that
> though should be to convert popen to a proper fork/exec() with a pipe.
>
> I'd prefer to introduce a single fork/exec helper that behaved properly
> instead of having to deal with cloexec everywhere.
No, unfortunately this doesn't work because it requires knowledge of all
execs. However, the glibc people believe that they are free to fork/exec
whenever they want in any function. Actually, the bug report that led to
this fix was triggered by a hidden fork/exec in glibc. I'm not convinced
that it's right what they're doing, but it's the way it is.
If you like to read it up, you can use
https://bugzilla.redhat.com/show_bug.cgi?id=528134 as a starting point
and dig through the referenced bugs.
Kevin
prev parent reply other threads:[~2009-11-17 9:02 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-13 15:17 [Qemu-devel] [PATCH] Don't leak file descriptors Kevin Wolf
2009-11-13 15:36 ` Scott Tsai
2009-11-16 2:15 ` Jamie Lokier
2009-11-13 15:41 ` Nathan Froyd
2009-11-13 15:44 ` Kevin Wolf
2009-11-13 21:05 ` Blue Swirl
2009-11-16 12:47 ` Kevin Wolf
2009-11-16 16:21 ` Blue Swirl
2009-11-16 16:46 ` Avi Kivity
2009-11-16 23:05 ` Jamie Lokier
2009-11-16 23:10 ` Jamie Lokier
2009-11-17 9:12 ` Kevin Wolf
2009-11-17 20:28 ` Blue Swirl
2009-11-16 23:26 ` Anthony Liguori
2009-11-16 23:44 ` Jamie Lokier
2009-11-17 9:00 ` Kevin Wolf [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=4B026649.8040603@redhat.com \
--to=kwolf@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=qemu-devel@nongnu.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).