daemon: ignore ENOTSOCK from setsockopt

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> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Eric Wong committed Jul 18, 2016 at 04:59 UTC 49c58d86ceb7816c5f0ca36e38e26cd6b8506d74
1 file changed +5 -3
daemon.c
+5 -3
@@ -673,9 +673,11 @@ static void set_keep_alive(int sockfd)
673 {
674 int ka = 1;
675
676 - if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0)
677 - logerror("unable to set SO_KEEPALIVE on socket: %s",
678 - strerror(errno));
676 + if (setsockopt(sockfd, SOL_SOCKET, SO_KEEPALIVE, &ka, sizeof(ka)) < 0) {
677 + if (errno != ENOTSOCK)
678 + logerror("unable to set SO_KEEPALIVE on socket: %s",
679 + strerror(errno));
680 + }
681 }
682
683 static int execute(void)