diff options
author | Chris Wilson <chris+github@qwirx.com> | 2008-03-28 22:18:44 +0000 |
---|---|---|
committer | Chris Wilson <chris+github@qwirx.com> | 2008-03-28 22:18:44 +0000 |
commit | 4fca88ed02c1f0b5208abf2420f73023de54c23e (patch) | |
tree | 51e882893d283f05b569bd27f7efab7b041c4548 /lib/server/Daemon.cpp | |
parent | 74bfdebe02405f7847fded96e42c1ccd297c9b9f (diff) |
Improve logging with macros that consistently output strerror(errno) and
errno, replacing almost all use of strerror() in the main code.
Log a more detailed error message before throwing an exception for some
more system call failures.
Make FileStream store its filename on all platforms, not just Windows.
Wrap some long lines at less than 80 characters to improve readability.
Fix some minor violations of coding standard (white space) and a typo
in a comment.
Diffstat (limited to 'lib/server/Daemon.cpp')
-rw-r--r-- | lib/server/Daemon.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/lib/server/Daemon.cpp b/lib/server/Daemon.cpp index 95f5c338..292a628c 100644 --- a/lib/server/Daemon.cpp +++ b/lib/server/Daemon.cpp @@ -465,8 +465,7 @@ int Daemon::Main(const std::string &rConfigFileName) // Set new session if(::setsid() == -1) { - BOX_ERROR("Failed to setsid(): " << - strerror(errno)); + BOX_LOG_SYS_ERROR("Failed to setsid()"); THROW_EXCEPTION(ServerException, DaemoniseFailed) } @@ -475,6 +474,7 @@ int Daemon::Main(const std::string &rConfigFileName) { case -1: // error + BOX_LOG_SYS_ERROR("Failed to fork() a child"); THROW_EXCEPTION(ServerException, DaemoniseFailed) break; @@ -497,9 +497,11 @@ int Daemon::Main(const std::string &rConfigFileName) struct sigaction sa; sa.sa_handler = SignalHandler; sa.sa_flags = 0; - sigemptyset(&sa.sa_mask); // macro - if(::sigaction(SIGHUP, &sa, NULL) != 0 || ::sigaction(SIGTERM, &sa, NULL) != 0) + sigemptyset(&sa.sa_mask); // macro + if(::sigaction(SIGHUP, &sa, NULL) != 0 || + ::sigaction(SIGTERM, &sa, NULL) != 0) { + BOX_LOG_SYS_ERROR("Failed to set signal handlers"); THROW_EXCEPTION(ServerException, DaemoniseFailed) } #endif // !WIN32 @@ -515,7 +517,8 @@ int Daemon::Main(const std::string &rConfigFileName) if(::write(pidFile, pid, pidsize) != pidsize) { - BOX_FATAL("can't write pid file"); + BOX_LOG_SYS_FATAL("Failed to write PID file: " << + pidFileName); THROW_EXCEPTION(ServerException, DaemoniseFailed) } @@ -544,6 +547,7 @@ int Daemon::Main(const std::string &rConfigFileName) int devnull = ::open(PLATFORM_DEV_NULL, O_RDWR, 0); if(devnull == -1) { + BOX_LOG_SYS_ERROR("Failed to open /dev/null"); THROW_EXCEPTION(CommonException, OSFileError); } // Then duplicate them to all three handles @@ -890,6 +894,8 @@ box_time_t Daemon::GetConfigFileModifiedTime() const { return 0; } + BOX_LOG_SYS_ERROR("Failed to stat configuration file: " << + GetConfigFileName()); THROW_EXCEPTION(CommonException, OSFileError) } |