{"thread":{"id":"42869","subject":"[PATCH] daemon: ignore ENOTSOCK from setsockopt","startedAt":"2016-07-18T05:00:28Z","lastAt":"2016-07-18T05:00:28Z","messageCount":1,"participants":["Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"291642","messageId":"20160718045911.GA7227@starla","threadId":"42869","inReplyTo":null,"subject":"[PATCH] daemon: ignore ENOTSOCK from setsockopt","fromName":"Eric Wong","fromEmail":"e@80x24.org","sentAt":"2016-07-18T04:59:11Z","receivedAt":"2016-07-18T05:00:28Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"In inetd mode, we are not guaranteed stdin or stdout is a\nsocket; callers could filter the data through a pipe\nor be testing with regular files.\n\nThis prevents t5802 from polluting syslog.\n\nSigned-off-by: Eric Wong <e@80x24.org>\n---\n daemon.c | 8 +++++---\n 1 file changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/daemon.c b/daemon.c\nindex 46dddac..a844951 100644\n--- a/daemon.c\n+++ b/daemon.c\n@@ -673,9 +673,11 @@ static void set_keep_alive(int sockfd)\n {\n \tint ka = 1;\n \n-\tif (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0)\n-\t\tlogerror(\"unable to set SO_KEEPALIVE on socket: %s\",\n-\t\t\tstrerror(errno));\n+\tif (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0) {\n+\t\tif (errno != ENOTSOCK)\n+\t\t\tlogerror(\"unable to set SO_KEEPALIVE on socket: %s\",\n+\t\t\t\tstrerror(errno));\n+\t}\n }\n \n static int execute(void)\n-- \nEW\n"}]}