diff options
author | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-08-16 00:10:03 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@tele2.at> | 2018-08-16 13:59:02 +0200 |
commit | d62ee95689e1e8c6fa4b395adfc8c0fcbca96b6f (patch) | |
tree | 95021f27e137640df91daffb826e10480cf59bb6 /syslogd/main.c | |
parent | 4311b9a2f14ee411ec3dc8b050f8efa25afa0bc5 (diff) |
Implement simple log rotation
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
Diffstat (limited to 'syslogd/main.c')
-rw-r--r-- | syslogd/main.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/syslogd/main.c b/syslogd/main.c index 8f11906..6b4937e 100644 --- a/syslogd/main.c +++ b/syslogd/main.c @@ -34,6 +34,7 @@ static volatile sig_atomic_t syslog_run = 1; +static volatile sig_atomic_t syslog_rotate = 0; static void sighandler(int signo) @@ -43,6 +44,9 @@ static void sighandler(int signo) case SIGTERM: syslog_run = 0; break; + case SIGHUP: + syslog_rotate = 1; + break; default: break; } @@ -57,6 +61,7 @@ static void signal_setup(void) sigaction(SIGINT, &act, NULL); sigaction(SIGTERM, &act, NULL); + sigaction(SIGHUP, &act, NULL); } static int handle_data(int fd) @@ -91,6 +96,11 @@ int main(void) goto out; while (syslog_run) { + if (syslog_rotate) { + logmgr->rotate(logmgr); + syslog_rotate = 0; + } + handle_data(sfd); } |