From 3ff9b2a5d32a2f6f2695598e9d9f3f433a2a653a Mon Sep 17 00:00:00 2001 From: Rafael Sadowski Date: Thu, 20 Oct 2016 18:36:38 +0200 Subject: [PATCH] remove to call C functions and use C++ std::fstream - Point std{in,out,err} descriptors to /dev/null (C++ wey) --- DaemonLinux.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/DaemonLinux.cpp b/DaemonLinux.cpp index 22d7dec8..16beeac0 100644 --- a/DaemonLinux.cpp +++ b/DaemonLinux.cpp @@ -74,13 +74,13 @@ namespace i2p LogPrint(eLogError, "Daemon: could not chdir: ", strerror(errno)); return false; } - - // point std{in,out,err} descriptors to /dev/null - stdin = freopen("/dev/null", "r", stdin); - stdout = freopen("/dev/null", "w", stdout); - stderr = freopen("/dev/null", "w", stderr); } + std::ofstream fout("/dev/null"); + std::cout.rdbuf(fout.rdbuf()); + std::cerr.rdbuf(fout.rdbuf()); + std::cin.rdbuf(fout.rdbuf()); + // Pidfile // this code is c-styled and a bit ugly, but we need fd for locking pidfile std::string pidfile; i2p::config::GetOption("pidfile", pidfile);