From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:33404) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StIOY-00059u-5D for qemu-devel@nongnu.org; Mon, 23 Jul 2012 09:09:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1StIOQ-0007HU-TS for qemu-devel@nongnu.org; Mon, 23 Jul 2012 09:09:54 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:44836) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StIOQ-0007HI-NM for qemu-devel@nongnu.org; Mon, 23 Jul 2012 09:09:46 -0400 Received: from /spool/local by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 23 Jul 2012 07:09:45 -0600 Received: from d03relay03.boulder.ibm.com (d03relay03.boulder.ibm.com [9.17.195.228]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id BFF4419D8042 for ; Mon, 23 Jul 2012 13:08:37 +0000 (WET) Received: from d03av01.boulder.ibm.com (d03av01.boulder.ibm.com [9.17.195.167]) by d03relay03.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id q6ND8GUS264304 for ; Mon, 23 Jul 2012 07:08:18 -0600 Received: from d03av01.boulder.ibm.com (loopback [127.0.0.1]) by d03av01.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id q6ND8FPQ021913 for ; Mon, 23 Jul 2012 07:08:15 -0600 From: Corey Bryant Date: Mon, 23 Jul 2012 09:08:00 -0400 Message-Id: <1343048885-1701-2-git-send-email-coreyb@linux.vnet.ibm.com> In-Reply-To: <1343048885-1701-1-git-send-email-coreyb@linux.vnet.ibm.com> References: <1343048885-1701-1-git-send-email-coreyb@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v5 1/6] qemu-char: Add MSG_CMSG_CLOEXEC flag to recvmsg List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, aliguori@us.ibm.com, stefanha@linux.vnet.ibm.com, libvir-list@redhat.com, Corey Bryant , lcapitulino@redhat.com, eblake@redhat.com Set the close-on-exec flag for the file descriptor received via SCM_RIGHTS. v4 -This patch is new in v4 (eblake@redhat.com) v5 -Fallback to FD_CLOEXEC if MSG_CMSG_CLOEXEC is not available (eblake@redhat.com, stefanha@linux.vnet.ibm.com) Signed-off-by: Corey Bryant --- 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