Skip to content
Snippets Groups Projects
Commit 3bf989e3 authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Merge remote-tracking branch 'origin/fix-logrotate-in-background'

parents 1e3b020f ba244796
No related branches found
No related tags found
No related merge requests found
...@@ -43,9 +43,10 @@ ...@@ -43,9 +43,10 @@
char log_path[PATH_MAX + 1]; char log_path[PATH_MAX + 1];
int log_fd = STDERR_FILENO; int log_fd = STDERR_FILENO;
int logger_nonblock; static int logger_nonblock;
pid_t logger_pid; pid_t logger_pid;
static bool booting = true; static bool booting = true;
static bool logger_background = true;
static const char *binary_filename; static const char *binary_filename;
static int log_level_default = S_INFO; static int log_level_default = S_INFO;
static int *log_level = &log_level_default; static int *log_level = &log_level_default;
...@@ -180,10 +181,11 @@ say_logrotate(int /* signo */) ...@@ -180,10 +181,11 @@ say_logrotate(int /* signo */)
S_IRUSR | S_IWUSR | S_IRGRP); S_IRUSR | S_IWUSR | S_IRGRP);
if (log_fd < 0) if (log_fd < 0)
return; return;
#if 0
dup2(log_fd, STDOUT_FILENO); if (logger_background) {
#endif dup2(log_fd, STDOUT_FILENO);
dup2(log_fd, STDERR_FILENO); dup2(log_fd, STDERR_FILENO);
}
if (logger_nonblock) { if (logger_nonblock) {
int flags = fcntl(log_fd, F_GETFL, 0); int flags = fcntl(log_fd, F_GETFL, 0);
fcntl(log_fd, F_SETFL, flags | O_NONBLOCK); fcntl(log_fd, F_SETFL, flags | O_NONBLOCK);
...@@ -216,6 +218,7 @@ say_logger_init(const char *path, int level, int nonblock, int background) ...@@ -216,6 +218,7 @@ say_logger_init(const char *path, int level, int nonblock, int background)
{ {
*log_level = level; *log_level = level;
logger_nonblock = nonblock; logger_nonblock = nonblock;
logger_background = background;
setvbuf(stderr, NULL, _IONBF, 0); setvbuf(stderr, NULL, _IONBF, 0);
if (path != NULL) { if (path != NULL) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment