remove to call C functions and use C++ std::fstream

- Point std{in,out,err} descriptors to /dev/null (C++ wey)
This commit is contained in:
Rafael Sadowski 2016-10-20 18:36:38 +02:00
parent 9980df2c67
commit 3ff9b2a5d3

View file

@ -74,13 +74,13 @@ namespace i2p
LogPrint(eLogError, "Daemon: could not chdir: ", strerror(errno)); LogPrint(eLogError, "Daemon: could not chdir: ", strerror(errno));
return false; 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 // Pidfile
// this code is c-styled and a bit ugly, but we need fd for locking 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); std::string pidfile; i2p::config::GetOption("pidfile", pidfile);