Account for the possibility of stderr not being open when we start.

This commit is contained in:
Ian Gulliver
2016-03-09 18:28:46 -08:00
parent 689bfc7939
commit 94744ef96f

View File

@@ -35,8 +35,10 @@ static void log_open() {
} }
int fd = open(log_path, O_WRONLY | O_CREAT | O_APPEND | O_NOCTTY | O_CLOEXEC, S_IRUSR | S_IWUSR); int fd = open(log_path, O_WRONLY | O_CREAT | O_APPEND | O_NOCTTY | O_CLOEXEC, S_IRUSR | S_IWUSR);
assert(fd >= 0); assert(fd >= 0);
if (fd != STDERR_FILENO) {
assert(dup3(fd, STDERR_FILENO, O_CLOEXEC) == STDERR_FILENO); assert(dup3(fd, STDERR_FILENO, O_CLOEXEC) == STDERR_FILENO);
assert(!close(fd)); assert(!close(fd));
}
} }
static void log_rotate() { static void log_rotate() {