From: René Scharfe Date: Fri, 26 Dec 2008 09:46:25 +0000 (+0100) Subject: daemon: handle freopen() failure X-Git-Tag: v1.6.1.1~40^2~3 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=c569b1fee151e467854ca268997f4f3baaf73564;p=git.git 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 Signed-off-by: Junio C Hamano --- diff --git a/daemon.c b/daemon.c index 1cef3098d..8c317bed4 100644 --- a/daemon.c +++ b/daemon.c @@ -1118,7 +1118,9 @@ int main(int argc, char **argv) struct sockaddr *peer = (struct sockaddr *)&ss; socklen_t slen = sizeof(ss); - freopen("/dev/null", "w", stderr); + if (!freopen("/dev/null", "w", stderr)) + die("failed to redirect stderr to /dev/null: %s", + strerror(errno)); if (getpeername(0, peer, &slen)) peer = NULL;