From: Kevin Wolf <kwolf@redhat.com>
To: Alexander Graf <agraf@suse.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] Don't leak file descriptors
Date: Wed, 02 Dec 2009 11:34:08 +0100 [thread overview]
Message-ID: <4B1642A0.5030701@redhat.com> (raw)
In-Reply-To: <4B153C60.2060605@suse.de>
[-- Attachment #1: Type: text/plain, Size: 520 bytes --]
Am 01.12.2009 16:55, schrieb Alexander Graf:
> 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>
>
> On Anthony's staging tree:
>
> cc1: warnings being treated as errors
> osdep.c: In function ‘qemu_accept’:
> osdep.c:304: error: implicit declaration of function ‘accept4’
Does this one on top work for you?
Kevin
[-- Attachment #2: fix_accept4.patch --]
[-- Type: text/plain, Size: 1315 bytes --]
diff --git a/configure b/configure
index dca5a43..0a1e347 100755
--- a/configure
+++ b/configure
@@ -1550,6 +1550,23 @@ if compile_prog "" "" ; then
pipe2=yes
fi
+# check if accept4 is there
+accept4=no
+cat > $TMPC << EOF
+#define _GNU_SOURCE
+#include <sys/socket.h>
+#include <stddef.h>
+
+int main(void)
+{
+ accept4(0, NULL, NULL, SOCK_CLOEXEC);
+ return 0;
+}
+EOF
+if compile_prog "" "" ; then
+ accept4=yes
+fi
+
# check if tee/splice is there. vmsplice was added same time.
splice=no
cat > $TMPC << EOF
@@ -2013,6 +2030,9 @@ fi
if test "$pipe2" = "yes" ; then
echo "CONFIG_PIPE2=y" >> $config_host_mak
fi
+if test "$accept4" = "yes" ; then
+ echo "CONFIG_ACCEPT4=y" >> $config_host_mak
+fi
if test "$splice" = "yes" ; then
echo "CONFIG_SPLICE=y" >> $config_host_mak
fi
diff --git a/osdep.c b/osdep.c
index 039065e..7509c5b 100644
--- a/osdep.c
+++ b/osdep.c
@@ -260,7 +260,7 @@ int qemu_pipe(int pipefd[2])
{
int ret;
-#ifdef O_CLOEXEC
+#ifdef CONFIG_PIPE2
ret = pipe2(pipefd, O_CLOEXEC);
#else
ret = pipe(pipefd);
@@ -300,7 +300,7 @@ int qemu_accept(int s, struct sockaddr *addr, socklen_t *addrlen)
{
int ret;
-#ifdef SOCK_CLOEXEC
+#ifdef CONFIG_ACCEPT4
ret = accept4(s, addr, addrlen, SOCK_CLOEXEC);
#else
ret = accept(s, addr, addrlen);
next prev parent reply other threads:[~2009-12-02 10:35 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-16 15:47 [Qemu-devel] [PATCH v2] Don't leak file descriptors Kevin Wolf
2009-12-01 15:55 ` Alexander Graf
2009-12-02 10:34 ` Kevin Wolf [this message]
-- strict thread matches above, loose matches on Subject: below --
2009-12-02 11:24 Kevin Wolf
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=4B1642A0.5030701@redhat.com \
--to=kwolf@redhat.com \
--cc=agraf@suse.de \
--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).