Account for the possibility of stderr not being open when we start.
This commit is contained in:
@@ -35,9 +35,11 @@ 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() {
|
||||||
assert(log_path);
|
assert(log_path);
|
||||||
|
|||||||
Reference in New Issue
Block a user