diff options
-rw-r--r-- | log.c | 6 | ||||
-rw-r--r-- | log.h | 2 | ||||
-rw-r--r-- | passt.c | 12 |
3 files changed, 11 insertions, 9 deletions
@@ -44,7 +44,7 @@ struct timespec log_start; /* Start timestamp */ int log_trace; /* --trace mode enabled */ bool log_conf_parsed; /* Logging options already parsed */ -bool log_runtime; /* Daemonised, or ready in foreground */ +bool log_stderr = true; /* Not daemonised, no shell spawned */ /** * logtime_fmt_and_arg() - Build format and arguments to print relative log time @@ -257,7 +257,7 @@ void vlogmsg(bool newline, int pri, const char *format, va_list ap) } if (debug_print || !log_conf_parsed || - (!log_runtime && (log_mask & LOG_MASK(LOG_PRI(pri))))) { + (log_stderr && (log_mask & LOG_MASK(LOG_PRI(pri))))) { (void)vfprintf(stderr, format, ap); if (newline && format[strlen(format)] != '\n') fprintf(stderr, "\n"); @@ -364,7 +364,7 @@ void passt_vsyslog(bool newline, int pri, const char *format, va_list ap) if (newline && format[strlen(format)] != '\n') n += snprintf(buf + n, BUFSIZ - n, "\n"); - if (log_sock >= 0 && send(log_sock, buf, n, 0) != n && !log_runtime) + if (log_sock >= 0 && send(log_sock, buf, n, 0) != n && log_stderr) fprintf(stderr, "Failed to send %i bytes to syslog\n", n); } @@ -43,7 +43,7 @@ void logmsg_perror(int pri, const char *format, ...) extern int log_trace; extern bool log_conf_parsed; -extern bool log_runtime; +extern bool log_stderr; extern struct timespec log_start; void trace_init(int enable); @@ -290,15 +290,17 @@ int main(int argc, char **argv) if (isolate_prefork(&c)) die("Failed to sandbox process, exiting"); - if (!c.foreground) + if (!c.foreground) { __daemon(c.pidfile_fd, devnull_fd); - else + log_stderr = false; + } else { pidfile_write(c.pidfile_fd, getpid()); + } - log_runtime = true; - - if (pasta_child_pid) + if (pasta_child_pid) { kill(pasta_child_pid, SIGUSR1); + log_stderr = false; + } isolate_postfork(&c); |