added a new parameter 'close_files' to App::daemonize()

This commit is contained in:
hyung-hwan 2021-12-06 16:22:10 +00:00
parent bb0fc4944d
commit d3a04da539
2 changed files with 3 additions and 3 deletions

View File

@ -86,7 +86,7 @@ public:
return this->_cmgr; 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_mchar_t* mpath) QSE_CPP_NOEXCEPT;
int chroot (const qse_wchar_t* wpath) QSE_CPP_NOEXCEPT; int chroot (const qse_wchar_t* wpath) QSE_CPP_NOEXCEPT;

View File

@ -129,7 +129,7 @@ void App::setName (const qse_char_t* name) QSE_CPP_NOEXCEPT
qse_log_setident (&this->_log.logger, name); 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; 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); QSE_UMASK (0);
if (chdir_to_root) QSE_CHDIR("/"); // don't care about failure if (chdir_to_root) QSE_CHDIR("/"); // don't care about failure
if (true) if (close_files)
{ {
int keep[] = { 0, 1, 2}; int keep[] = { 0, 1, 2};