diff --git a/base/utility.cpp b/base/utility.cpp index ece0c12c7..2a078d77f 100644 --- a/base/utility.cpp +++ b/base/utility.cpp @@ -44,16 +44,16 @@ void Utility::Daemonize(void) { if (fd < 0) throw PosixException("open() failed", errno); - if (fd != 0) - dup2(fd, 0); + if (fd != STDIN_FILENO) + dup2(fd, STDIN_FILENO); - if (fd != 1) - dup2(fd, 1); + if (fd != STDOUT_FILENO) + dup2(fd, STDOUT_FILENO); - if (fd != 2) - dup2(fd, 2); + if (fd != STDERR_FILENO) + dup2(fd, STDERR_FILENO); - if (fd > 2) + if (fd > STDERR_FILENO) close(fd); if (setsid() < 0)