From c569b1fee151e467854ca268997f4f3baaf73564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Scharfe?= Date: Fri, 26 Dec 2008 10:46:25 +0100 Subject: 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 --- daemon.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) 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; -- cgit v1.2.1