Skip to content

Commit 49c58d8

Browse files
Eric Wonggitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a43b68a commit 49c58d8

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

daemon.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -673,9 +673,11 @@ static void set_keep_alive(int sockfd)
673673
{
674674
int ka = 1;
675675

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+
}
679681
}
680682

681683
static int execute(void)

0 commit comments

Comments
 (0)