Skip to content

Commit

Permalink
daemon: handle freopen() failure
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
René Scharfe authored and Junio C Hamano committed Dec 27, 2008
1 parent 8104ebf commit c569b1f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion daemon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c569b1f

Please sign in to comment.