From 7bbe926232c870b975170e22ef4546221b954ef0 Mon Sep 17 00:00:00 2001 From: hagen Date: Fri, 25 Mar 2016 04:00:27 +0000 Subject: [PATCH] * use freopen() instead close()/open() : avoid potential fd leak --- DaemonLinux.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/DaemonLinux.cpp b/DaemonLinux.cpp index 53d9f61e..59c286be 100644 --- a/DaemonLinux.cpp +++ b/DaemonLinux.cpp @@ -64,12 +64,9 @@ namespace i2p } // close stdin/stdout/stderr descriptors - ::close (0); - ::open ("/dev/null", O_RDWR); - ::close (1); - ::open ("/dev/null", O_RDWR); - ::close (2); - ::open ("/dev/null", O_RDWR); + freopen("/dev/null", "r", stdin); + freopen("/dev/null", "w", stdout); + freopen("/dev/null", "w", stderr); } // Pidfile