Skip to content

Commit c569b1f

Browse files
René Scharfegitster
authored andcommitted
daemon: handle freopen() failure
Die if stderr couldn't be sent to /dev/null when operating in inetd mode and report the error message from the OS. This fixes a compiler warning about the return value of freopen() being ignored on Ubuntu 8.10. Signed-off-by: Rene Scharfe <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8104ebf commit c569b1f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

daemon.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,9 @@ int main(int argc, char **argv)
11181118
struct sockaddr *peer = (struct sockaddr *)&ss;
11191119
socklen_t slen = sizeof(ss);
11201120

1121-
freopen("/dev/null", "w", stderr);
1121+
if (!freopen("/dev/null", "w", stderr))
1122+
die("failed to redirect stderr to /dev/null: %s",
1123+
strerror(errno));
11221124

11231125
if (getpeername(0, peer, &slen))
11241126
peer = NULL;

0 commit comments

Comments
 (0)