new config option, stdout/stdin closed

Now stdin and stdout get closed. Additionally stderr gets closed and
reopened to the new config option „logfile“ if specified
This commit is contained in:
Christian Kruse
2014-01-16 15:22:34 +01:00
parent 4f3bd6612c
commit 9563877fbb
7 changed files with 21 additions and 5 deletions

10
log.c
View File

@@ -68,7 +68,7 @@ static int detect_log_facility(const char* facility);
int log_type = REPMGR_STDERR;
int log_level = LOG_NOTICE;
bool logger_init(const char* ident, const char* level, const char* facility)
bool logger_init(t_configuration_options *opts, const char* ident, const char* level, const char* facility)
{
int l;
@@ -140,6 +140,14 @@ bool logger_init(const char* ident, const char* level, const char* facility)
#endif
fclose(stdin);
fclose(stdout);
if (*opts->logfile)
{
freopen(opts->logfile, "a", stderr);
}
return true;
}