From d3a04da539a64721e5a3c4dfab52d1a812764659 Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 6 Dec 2021 16:22:10 +0000 Subject: [PATCH] added a new parameter 'close_files' to App::daemonize() --- qse/include/qse/si/App.hpp | 2 +- qse/lib/si/App.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qse/include/qse/si/App.hpp b/qse/include/qse/si/App.hpp index ed254625..5fd4be65 100644 --- a/qse/include/qse/si/App.hpp +++ b/qse/include/qse/si/App.hpp @@ -86,7 +86,7 @@ public: return this->_cmgr; } - int daemonize (bool chdir_to_root = true, int fork_count = 1, bool root_only = false) QSE_CPP_NOEXCEPT; + int daemonize (bool chdir_to_root = true, int fork_count = 1, bool root_only = false, bool close_files = true) QSE_CPP_NOEXCEPT; int chroot (const qse_mchar_t* mpath) QSE_CPP_NOEXCEPT; int chroot (const qse_wchar_t* wpath) QSE_CPP_NOEXCEPT; diff --git a/qse/lib/si/App.cpp b/qse/lib/si/App.cpp index 16ee8f0d..d40371c8 100644 --- a/qse/lib/si/App.cpp +++ b/qse/lib/si/App.cpp @@ -129,7 +129,7 @@ void App::setName (const qse_char_t* name) QSE_CPP_NOEXCEPT qse_log_setident (&this->_log.logger, name); } -int App::daemonize (bool chdir_to_root, int fork_count, bool root_only) QSE_CPP_NOEXCEPT +int App::daemonize (bool chdir_to_root, int fork_count, bool root_only, bool close_files) QSE_CPP_NOEXCEPT { if (root_only && QSE_GETEUID() != 0) return -1; @@ -152,7 +152,7 @@ int App::daemonize (bool chdir_to_root, int fork_count, bool root_only) QSE_CPP_ QSE_UMASK (0); if (chdir_to_root) QSE_CHDIR("/"); // don't care about failure - if (true) + if (close_files) { int keep[] = { 0, 1, 2};