aboutsummaryrefslogtreecommitdiff
path: root/src/pies.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pies.c')
-rw-r--r--src/pies.c48
1 files changed, 20 insertions, 28 deletions
diff --git a/src/pies.c b/src/pies.c
index 0536824..a9f612f 100644
--- a/src/pies.c
+++ b/src/pies.c
@@ -22,7 +22,7 @@
char *conffile = SYSCONFDIR "/pies.conf";
int preprocess_only; /* Preprocess config, do nothing more */
int lint_mode; /* Test configuration syntax and exit */
-int log_to_stderr; /* Use stderr for logging */
+int log_to_stderr_only; /* Use only stderr for logging */
int log_facility = LOG_USER;
char *log_tag;
struct pies_privs pies_privs;
@@ -73,13 +73,6 @@ add_pp_option (const char *opt, const char *arg)
/* Logging */
-void
-log_setup (int want_stderr)
-{
- if (!want_stderr)
- openlog (log_tag, LOG_PID, log_facility);
-}
-
static int
stderr_closed_p ()
{
@@ -1235,7 +1228,7 @@ config_init ()
grecs_set_keywords (pies_keywords);
grecs_include_path_setup (DEFAULT_VERSION_INCLUDE_DIR,
DEFAULT_INCLUDE_DIR, NULL);
- grecs_log_to_stderr = log_to_stderr;
+ grecs_log_to_stderr = log_to_stderr_only;
if (DEFAULT_PREPROCESSOR)
{
obstack_init (&pp_stk);
@@ -1353,7 +1346,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
break;
case 't':
- log_to_stderr = 1;
+ log_to_stderr_only = 1;
lint_mode = 1;
break;
@@ -1362,7 +1355,7 @@ parse_opt (int key, char *arg, struct argp_state *state)
exit (0);
case OPT_FOREGROUND:
- log_to_stderr = 1;
+ log_to_stderr_only = 1;
foreground = 1;
break;
@@ -1372,16 +1365,16 @@ parse_opt (int key, char *arg, struct argp_state *state)
case OPT_RESTART:
case OPT_DUMP_PREREQ:
case OPT_DUMP_DEPMAP:
- log_to_stderr = 1;
+ log_to_stderr_only = 1;
command = key;
break;
case OPT_SYSLOG:
- log_to_stderr = 0;
+ log_to_stderr_only = 0;
break;
case OPT_STDERR:
- log_to_stderr = 1;
+ log_to_stderr_only = 1;
break;
case 'x':
@@ -1830,8 +1823,8 @@ main (int argc, char **argv)
set_quoting_style (NULL, shell_quoting_style);
/* Set default logging */
- log_to_stderr = !stderr_closed_p ();
- log_setup (log_to_stderr);
+ diag_setup (DIAG_TO_SYSLOG | (stderr_closed_p () ? 0 : DIAG_TO_STDERR));
+
config_init ();
argp_program_version_hook = version;
if (argp_parse (&argp, argc, argv, 0, &index, NULL))
@@ -1860,8 +1853,8 @@ main (int argc, char **argv)
}
/* Re-setup logging: it might have been reset in the config file */
- log_setup (log_to_stderr);
-
+ diag_setup (log_to_stderr_only ? DIAG_TO_STDERR : 0);
+
if (argc != index && command != 'R')
{
logmsg (LOG_ERR, "extra command line arguments");
@@ -1921,20 +1914,19 @@ main (int argc, char **argv)
exit (EX_USAGE);
}
- if (!foreground)
- log_setup (log_to_stderr = 0);
-
logmsg (LOG_INFO, _("%s starting"), program_version);
if (!foreground)
- check_pidfile (pidfile);
-
- if (!foreground && daemon (0, 0) == -1)
{
- logmsg (LOG_ERR, _("cannot become a daemon: %s"), strerror (errno));
- exit (EX_SOFTWARE);
+ check_pidfile (pidfile);
+ if (daemon (0, 0) == -1)
+ {
+ logmsg (LOG_ERR, _("cannot become a daemon: %s"), strerror (errno));
+ exit (EX_SOFTWARE);
+ }
+ diag_setup (DIAG_TO_SYSLOG);
}
-
+
create_pidfile (pidfile);
if (argv[0][0] != '/')
@@ -1985,7 +1977,7 @@ main (int argc, char **argv)
if (action == ACTION_RESTART && argv[0][0] == '/')
{
- int minfd = log_to_stderr ? 2 : 0;
+ int minfd = DIAG_OUTPUT (DIAG_TO_STDERR) ? 2 : 0;
int i;
for (i = getmaxfd (); i > minfd; i--)

Return to:

Send suggestions and report system problems to the System administrator.