[PATCH 1/3] daemon: handle freopen() failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxx>
---
 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



--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux