repmgrd: add stdout/stderr redirects

This commit is contained in:
Ian Barwick
2017-06-23 22:41:58 +09:00
parent 8117d4dcc4
commit 27ad7b4f79

View File

@@ -63,6 +63,8 @@ main(int argc, char **argv)
RecordStatus record_status;
FILE *fd;
static struct option long_options[] =
{
/* general options */
@@ -221,11 +223,38 @@ main(int argc, char **argv)
config_file_options.monitoring_history = true;
}
fd = freopen("/dev/null", "r", stdin);
if (fd == NULL)
{
fprintf(stderr, "error reopening stdin to \"/dev/null\":\n %s\n",
strerror(errno));
}
fd = freopen("/dev/null", "w", stdout);
if (fd == NULL)
{
fprintf(stderr, "error reopening stdout to \"/dev/null\":\n %s\n",
strerror(errno));
}
logger_init(&config_file_options, progname());
if (verbose)
logger_set_verbose();
if (log_type == REPMGR_SYSLOG)
{
fd = freopen("/dev/null", "w", stderr);
if (fd == NULL)
{
fprintf(stderr, "error reopening stderr to \"/dev/null\":\n %s\n",
strerror(errno));
}
}
log_info(_("connecting to database \"%s\""),
config_file_options.conninfo);
@@ -334,6 +363,8 @@ main(int argc, char **argv)
setup_event_handlers();
#endif
start_monitoring();
logger_shutdown();