From 276a61672a0b10d797225e8d1e4e4abf283a3249 Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Tue, 5 Jul 2011 02:36:22 +0300 Subject: Improve reporting of startup errors. HUP restarts the program only if syntax check succeeds. * lib/libmf.h (mf_server_lint_option): New extern. * lib/server.c (mf_server_lint_option): New global variable. (sig_restart): Don't call mfd_srvman_stop. (run_lint,server_idle_hook): New functions. (mf_server_start): Install idle hook. HUP restarts the program only if syntax check succeeds. Close fds above 2 if using stderr for error output, and from 1 if using syslog. * src/calloutd.c (main): Call mu_stdstream_setup. Set mf_server_lint_option. * src/main.c (main): Check whether stderr is open as early as possible. Update call to mu_stdstream_setup (needs MU 5e1d982ec). Set mf_server_lint_option. * src/srvcfg.c (srv_parse_opt): Make sure --syslog takes effect at once. --- src/main.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index 090be692..cc0852df 100644 --- a/src/main.c +++ b/src/main.c @@ -1166,6 +1166,7 @@ main(int argc, char **argv) int index; prog_counter_t entry_point; struct arguments args; + int stderr_is_closed = stderr_closed_p(); mf_init_nls(); mf_proctitle_init(argc, argv, environ); @@ -1179,11 +1180,11 @@ main(int argc, char **argv) yy_flex_debug = 0; /* Set default logging */ - mu_set_program_name (argv[0]); + mu_set_program_name(argv[0]); mu_log_tag = (char*)mu_program_name; mu_log_facility = DEFAULT_LOG_FACILITY; - mu_stdstream_setup (); - mf_srvcfg_log_setup(stderr_closed_p() ? "syslog" : "stderr"); + mu_stdstream_setup(MU_STDSTREAM_RESET_NONE); + mf_srvcfg_log_setup(stderr_is_closed ? "syslog" : "stderr"); debug_init(modnames); libcallout_init(); @@ -1329,6 +1330,7 @@ main(int argc, char **argv) server_flags |= MF_SERVER_NORESTART; } open_strecho(1); + mf_server_lint_option = "--lint"; mf_server_start("mailfromd", mailfromd_state_dir, pidfile, server_flags); break; -- cgit v1.2.1