git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] daemon: ignore ENOTSOCK from setsockopt

From
EWEric Wong <e@80x24.org>
Date
Jul 18, 2016, 04:59 UTC
Message-ID
<20160718045911.GA7227@starla>

In inetd mode, we are not guaranteed stdin or stdout is a socket; callers could filter the data through a pipe or be testing with regular files.

This prevents t5802 from polluting syslog.
Signed-off-by: Eric Wong <e@80x24.org>
---
 daemon.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/daemon.c b/daemon.c
index 46dddac..a844951 100644
--- a/daemon.c
+++ b/daemon.c
@@ -673,9 +673,11 @@ static void set_keep_alive(int sockfd)
 {
 	int ka = 1;
 
-	if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0)
-		logerror("unable to set SO_KEEPALIVE on socket: %s",
-			strerror(errno));
+	if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0) {
+		if (errno != ENOTSOCK)
+			logerror("unable to set SO_KEEPALIVE on socket: %s",
+				strerror(errno));
+	}
 }
 
 static int execute(void)
-- 
EW
Message 1 of 1 in “daemon: ignore ENOTSOCK from setsockopt”
  1. daemon: ignore ENOTSOCK from setsockoptEric Wong, Jul 18, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.