From 9d113e9bb8b7d57b4a088d4991674ff068ac56bf Mon Sep 17 00:00:00 2001 From: auric Date: Sun, 22 Feb 2026 18:18:36 -0600 Subject: Fix log tail rotation handling and SIGHUP cleanup - Detect IN_MOVE_SELF/IN_DELETE_SELF events in log_tail_handle and re-open the watched path so srcds log rotation is followed correctly - Parse inotify events rather than blindly draining them - Call log_tail_cleanup() before log_tail_init() on SIGHUP to prevent fd leaks on reload Co-Authored-By: Claude Sonnet 4.6 --- src/main.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/main.c') diff --git a/src/main.c b/src/main.c index f242489..901ce74 100644 --- a/src/main.c +++ b/src/main.c @@ -59,10 +59,11 @@ static void handle_signal(void) { case SIGHUP: log_info("SIGHUP received — reloading units"); + log_tail_cleanup(); /* Reload unit descriptors. Existing runtime state is preserved. */ g.unit_count = 0; unit_load_all(); - log_tail_init(); + log_tail_init(); break; } } @@ -206,8 +207,6 @@ int main(int argc, char *argv[]) { ev.data.fd = g.signal_fd; epoll_ctl(g.epoll_fd, EPOLL_CTL_ADD, g.signal_fd, &ev); - log_tail_init(); - /* Load unit descriptors */ if (unit_load_all() < 0) { log_error("Failed to load units"); @@ -215,6 +214,8 @@ int main(int argc, char *argv[]) { return 1; } + log_tail_init(); + /* Set up listening socket */ g.listen_fd = client_listen(); if (g.listen_fd < 0) { -- cgit v1.2.3