git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] daemon: handle freopen() failure
@ 2008-12-26  9:46 René Scharfe
  2008-12-26 10:01 ` [PATCH 2/3] daemon: cleanup: replace loop with if René Scharfe
  2008-12-26 10:17 ` [PATCH] merge-file: handle freopen() failure René Scharfe
  0 siblings, 2 replies; 4+ messages in thread
From: René Scharfe @ 2008-12-26  9:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List

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 <rene.scharfe@lsrfire.ath.cx>
---
 daemon.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/daemon.c b/daemon.c
index 1cef309..8c317be 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;
-- 
1.6.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-12-26 10:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-26  9:46 [PATCH 1/3] daemon: handle freopen() failure René Scharfe
2008-12-26 10:01 ` [PATCH 2/3] daemon: cleanup: replace loop with if René Scharfe
2008-12-26 10:12   ` [PATCH 3/3] daemon: cleanup: factor out xstrdup_tolower() René Scharfe
2008-12-26 10:17 ` [PATCH] merge-file: handle freopen() failure René Scharfe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).