From 3ff9b2a5d32a2f6f2695598e9d9f3f433a2a653a Mon Sep 17 00:00:00 2001 From: Rafael Sadowski Date: Thu, 20 Oct 2016 18:36:38 +0200 Subject: [PATCH 1/2] 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); From 934c8b214476f9d16c7a2199ac13cf5316bc7a25 Mon Sep 17 00:00:00 2001 From: Rafael Sadowski Date: Thu, 20 Oct 2016 18:46:45 +0200 Subject: [PATCH 2/2] CMake: use SBINDIR for system admin executables (sbin) -see https://cmake.org/cmake/help/v3.0/module/GNUInstallDirs.html --- build/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 00048942..e2932703 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -407,7 +407,7 @@ if (WITH_BINARY) endif() target_link_libraries( "${PROJECT_NAME}" libi2pd i2pdclient ${DL_LIB} ${Boost_LIBRARIES} ${OPENSSL_LIBRARIES} ${ZLIB_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${MINGW_EXTRA} ${DL_LIB}) - install(TARGETS "${PROJECT_NAME}" RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime) + install(TARGETS "${PROJECT_NAME}" RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} COMPONENT Runtime) set (APPS "\${CMAKE_INSTALL_PREFIX}/bin/${PROJECT_NAME}${CMAKE_EXECUTABLE_SUFFIX}") set (DIRS "${Boost_LIBRARY_DIR};${OPENSSL_INCLUDE_DIR}/../bin;${ZLIB_INCLUDE_DIR}/../bin;/mingw32/bin") if (MSVC)