logclose is meant to free resources.
On Linux this means that _log_prog is also free'd and once in the
chroot we cannot work it out again.
As such allow logopen to close what it needs to so that reopening
works.
if (ps_root_logreopen(ctx) == -1)
logerr("ps_root_logreopen");
} else {
- logclose();
if (logopen(ctx->logfile) == -1)
logerr("logopen");
}
(void)setvbuf(stderr, ctx->log_buf, _IOLBF, sizeof(ctx->log_buf));
+#ifndef SMALL
+ if (ctx->log_file != NULL) {
+ fclose(ctx->log_file);
+ ctx->log_file = NULL;
+ }
+#endif
+
if (ctx->log_opts & LOGERR_LOG_PID)
opts |= LOG_PID;
openlog(getprogname(), opts, LOGERR_SYSLOG_FACILITY);
void logsettag(const char *);
#endif
+/* Can be called more than once. */
int logopen(const char *);
+
+/* Should only be called at program exit. */
void logclose(void);
-int logreopen(void);
#endif
}
break;
case PS_LOGREOPEN:
- logclose();
err = logopen(ctx->logfile);
break;
#ifdef AUTH