patches and low-level development discussion
 help / color / mirror / code / Atom feed
From: Alyssa Ross <>
Cc: Cole Helbling <>
Subject: [PATCH ucspi-vsock] vsock_accept: return fd instead of 0 on success
Date: Wed, 10 Mar 2021 20:45:16 +0000	[thread overview]
Message-ID: <> (raw)

This would result in the spawned process being hooked up to stdin,
instead of the vsock.  Then stdin would be closed, so subsequent
processes would be connected to nothing.  Oops.

I am... a bit embarassed that I didn't notice this after already
fixing the exact same problem in vsock_connect[1].

Maybe I can write an integration test that runs vsockserver and
vsockclient and checks they actually do the right thing...


 vsock.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/vsock.c b/vsock.c
index d9ff3b6..e6a173c 100644
--- a/vsock.c
+++ b/vsock.c
@@ -32,14 +32,15 @@ int vsock_accept(int sockfd, uint32_t *cid, uint32_t *port)
 	struct sockaddr_vm addr = { 0 };
 	socklen_t addr_size = sizeof addr;
+	int fd;
-	if (accept(sockfd, (struct sockaddr *)&addr, &addr_size) == -1)
+	if ((fd = accept(sockfd, (struct sockaddr *)&addr, &addr_size)) == -1)
 		return -1;
 	*cid = addr.svm_cid;
 	*port = addr.svm_port;
-	return 0;
+	return fd;
 int vsock_connect(int fd, uint32_t cid, uint32_t port)

             reply	other threads:[~2021-03-10 20:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-10 20:45 Alyssa Ross [this message]
2021-03-10 20:48 ` Cole Helbling

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \
    --subject='Re: [PATCH ucspi-vsock] vsock_accept: return fd instead of 0 on success' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Code repositories for project(s) associated with this inbox:

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).