Reload log file on SIGHUP

There's a report about a nightly "crash" when users download, compile
from source, and replace their distro's mindlnad binary.  This is because
the Debian package includes a patch that uses SIGUSR2 to reopen the log
file and sends SIGUSR2 from logrotate instead of just using the
"copytruncate" logrotate option.  Then logrotate sends SIGUSR2 at 6:25AM,
which causes us to abort due to the unhandled signal.

I don't want to sacrifice SIGUSR2 just for log rotation, especially when
we already do some reload operations on SIGHUP.  So to avoid this
Debian/Ubuntu issue, we'll explicitly ignore SIGUSR2, and add log file
reopening to the SIGHUP handler.  Then hopefully a future Debian package
version will remove the SIGUSR2 patch and use SIGHUP instead (or
copytruncate).

Fixes: SF Bug #313 (log rotation kills minidlna service)
This commit is contained in:
Justin Maggard
2018-01-23 22:01:10 -08:00
parent 7a8ef80af0
commit 138d03db19
5 changed files with 67 additions and 50 deletions

3
log.h
View File

@ -44,8 +44,9 @@ enum _log_facility
};
extern int log_level[L_MAX];
extern int log_init(const char *fname, const char *debug);
extern int log_init(const char *debug);
extern void log_close(void);
extern void log_reopen(void);
extern void log_err(int level, enum _log_facility facility, char *fname, int lineno, char *fmt, ...)
__attribute__((__format__ (__printf__, 5, 6)));