[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v5 1/6] qemu-char: Add MSG_CMSG_CLOEXEC flag to recv
From: |
Corey Bryant |
Subject: |
[Qemu-devel] [PATCH v5 1/6] qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg |
Date: |
Mon, 23 Jul 2012 09:08:00 -0400 |
Set the close-on-exec flag for the file descriptor received
via SCM_RIGHTS.
v4
-This patch is new in v4 (address@hidden)
v5
-Fallback to FD_CLOEXEC if MSG_CMSG_CLOEXEC is not available
(address@hidden, address@hidden)
Signed-off-by: Corey Bryant <address@hidden>
---
qemu-char.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/qemu-char.c b/qemu-char.c
index c2aaaee..eedf66d 100644
--- a/qemu-char.c
+++ b/qemu-char.c
@@ -2263,9 +2263,17 @@ static ssize_t tcp_chr_recv(CharDriverState *chr, char
*buf, size_t len)
msg.msg_control = &msg_control;
msg.msg_controllen = sizeof(msg_control);
+#ifdef MSG_CMSG_CLOEXEC
+ ret = recvmsg(s->fd, &msg, MSG_CMSG_CLOEXEC);
+#else
ret = recvmsg(s->fd, &msg, 0);
- if (ret > 0 && s->is_unix)
+ if (ret > 0) {
+ qemu_set_cloexec(s->fd);
+ }
+#endif
+ if (ret > 0 && s->is_unix) {
unix_process_msgfd(chr, &msg);
+ }
return ret;
}
--
1.7.10.4
- [Qemu-devel] [PATCH v5 3/6] monitor: Clean up fd sets on monitor disconnect, (continued)
Re: [Qemu-devel] [PATCH v5 6/6] block: Enable qemu_open/close to work with fd sets, Eric Blake, 2012/07/25
[Qemu-devel] [PATCH v5 5/6] block: Convert close calls to qemu_close, Corey Bryant, 2012/07/23
[Qemu-devel] [PATCH v5 1/6] qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg,
Corey Bryant <=
[Qemu-devel] [PATCH v5 4/6] block: Convert open calls to qemu_open, Corey Bryant, 2012/07/23
[Qemu-devel] [PATCH v5 2/6] qapi: Introduce add-fd, remove-fd, query-fdsets, Corey Bryant, 2012/07/23
Re: [Qemu-devel] [PATCH v5 0/6] file descriptor passing using fd sets, Kevin Wolf, 2012/07/24