50constexpr int MAXIMUM_FILE_DESC = 256;
56void redirect_standard_fds()
58 const int null_fd = open(
"/dev/null", O_RDWR);
63 <<
"Cannot redirect stdin";
66 <<
"Cannot redirect stdout";
69 <<
"Cannot redirect stderr";
72 if (null_fd > STDERR_FILENO)
78void daemonize(
const char *program_name,
int facility)
82 <<
"Program name cannot be null or empty";
95 Signal signalHandler(SIGHUP, SIG_IGN);
111 for (
int i = 0; i < MAXIMUM_FILE_DESC; i++)
115 redirect_standard_fds();
118 openlog(program_name, LOG_PID | LOG_NDELAY, facility);
121 #ifdef ALEPH_DAEMONIZED_FLAG
Exception handling system with formatted messages for Aleph-w.
#define ah_runtime_error_if(C)
Throws std::runtime_error if condition holds.
#define ah_invalid_argument_if(C)
Throws std::invalid_argument if condition holds.
POSIX signal handling utilities with RAII semantics.
void daemonize(const char *program_name, int facility)
Converts the calling process into a Unix daemon.
Functionality for daemonizing a process.
RAII wrapper for POSIX signal handler registration.
bool daemonized
Flag indicating if the process is running as a daemon.