diff options
Diffstat (limited to 'degesch.c')
-rw-r--r-- | degesch.c | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -1302,6 +1302,8 @@ struct app_context struct poller_fd tty_event; ///< Terminal input event struct poller_fd signal_event; ///< Signal FD event + struct poller_timer flush_timer; ///< Flush all open files (e.g. logs) + struct poller poller; ///< Manages polled descriptors bool quitting; ///< User requested quitting bool polling; ///< The event loop is running @@ -8499,6 +8501,20 @@ on_tty_readable (const struct pollfd *fd, struct app_context *ctx) } static void +rearm_flush_timer (struct app_context *ctx) +{ + poller_timer_set (&ctx->flush_timer, 60 * 1000); +} + +static void +on_flush_timer (struct app_context *ctx) +{ + // I guess we don't need to do anything more complicated + fflush (NULL); + rearm_flush_timer (ctx); +} + +static void init_poller_events (struct app_context *ctx) { poller_fd_init (&ctx->signal_event, &ctx->poller, g_signal_pipe[0]); @@ -8510,6 +8526,11 @@ init_poller_events (struct app_context *ctx) ctx->tty_event.dispatcher = (poller_fd_fn) on_tty_readable; ctx->tty_event.user_data = ctx; poller_fd_set (&ctx->tty_event, POLLIN); + + poller_timer_init (&ctx->flush_timer, &ctx->poller); + ctx->flush_timer.dispatcher = (poller_timer_fn) on_flush_timer; + ctx->flush_timer.user_data = ctx; + rearm_flush_timer (ctx); } // --- Main program ------------------------------------------------------------ |