[PATCH] make 'syslog-ng -s' stay in the foreground
Hi, I recently upgraded to syslog-ng 3.1.1 and noticed messages like this appearing on terminals owned by root: 2010 May 7 06:25:21 fire Daemon exited gracefully, not restarting; exitcode='0' This is triggered by a daily logrotate cron job that runs 'syslog-ng -s' before sending the daemon a SIGHUP. It seems that 'syslog-ng -s' will daemonize and fork; the child process runs the syntax check and exits immediately, and then the parent process sends the above message via syslog(LOG_CRIT,...). I can work around it by using 'syslog-ng -sF', but I also hacked up a small patch to force the process to be in the foreground when -s is specified. Is this useful? If not, I'll send a patch to Debian to use 'syslog-ng -sF' instead. Thanks, Corey diff -ur syslog-ng-3.1.1.orig/src/gprocess.c syslog-ng-3.1.1/src/gprocess.c --- syslog-ng-3.1.1.orig/src/gprocess.c 2009-12-15 05:00:28.000000000 -0800 +++ syslog-ng-3.1.1/src/gprocess.c 2010-05-08 19:30:12.000000000 -0700 @@ -1134,14 +1134,18 @@ /** * g_process_start: + * @force_foreground: force process mode to foreground * * Start the process as directed by the options set by various * g_process_set_*() functions. **/ void -g_process_start(void) +g_process_start(gboolean force_foreground) { pid_t pid; + + if (force_foreground) + process_opts.mode = G_PM_FOREGROUND; g_process_detach_tty(); g_process_change_limits(); diff -ur syslog-ng-3.1.1.orig/src/gprocess.h syslog-ng-3.1.1/src/gprocess.h --- syslog-ng-3.1.1.orig/src/gprocess.h 2009-11-25 11:47:45.000000000 -0800 +++ syslog-ng-3.1.1/src/gprocess.h 2010-05-08 19:28:55.000000000 -0700 @@ -70,7 +70,7 @@ void g_process_set_use_fdlimit(gboolean use); void g_process_set_check(gint check_period, gboolean (*check_fn)(void)); -void g_process_start(void); +void g_process_start(gboolean force_foreground); void g_process_startup_failed(guint ret_num, gboolean may_exit); void g_process_startup_ok(void); void g_process_finish(void); diff -ur syslog-ng-3.1.1.orig/src/main.c syslog-ng-3.1.1/src/main.c --- syslog-ng-3.1.1.orig/src/main.c 2010-03-14 10:22:50.000000000 -0700 +++ syslog-ng-3.1.1/src/main.c 2010-05-08 19:28:55.000000000 -0700 @@ -417,7 +417,7 @@ /* in this case we switch users early while retaining a limited set of * credentials in order to initialize/reinitialize the configuration. */ - g_process_start(); + g_process_start(syntax_only); rc = initial_init(&cfg); if (rc)
On Sat, 2010-05-08 at 19:32 -0700, Corey Hickey wrote:
Hi,
I recently upgraded to syslog-ng 3.1.1 and noticed messages like this appearing on terminals owned by root:
2010 May 7 06:25:21 fire Daemon exited gracefully, not restarting; exitcode='0'
This is triggered by a daily logrotate cron job that runs 'syslog-ng -s' before sending the daemon a SIGHUP. It seems that 'syslog-ng -s' will daemonize and fork; the child process runs the syntax check and exits immediately, and then the parent process sends the above message via syslog(LOG_CRIT,...).
I can work around it by using 'syslog-ng -sF', but I also hacked up a small patch to force the process to be in the foreground when -s is specified. Is this useful? If not, I'll send a patch to Debian to use 'syslog-ng -sF' instead.
I've slightly changed your patch, but the goal is the same: commit 5f82516db500209df040215c39da1b5adfc4d143 Author: Balazs Scheidler <bazsi@balabit.hu> Date: Mon May 10 17:50:22 2010 +0200 main: stay in foreground if syntax-check or debug is requested There's simply no reason to go into the background just to check the syntax of the configuration file. Likewise, debug messages may generate feedback loops in the configuration thus it is not safe to enable them unless internal messages are only going to the stderr and syslog-ng is configured to be run in the foreground. Reported-By: Corey Hickey It is on syslog-ng 3.0 master, but will eventually be forward ported to the 3.1 branch as well. -- Bazsi
participants (2)
-
Balazs Scheidler
-
Corey Hickey