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); 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)