mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-18 06:46:23 -04:00
Implement live-reload of config colors on SIGUSR1.
This commit is contained in:
parent
a50f78c599
commit
341cdabdd2
7 changed files with 87 additions and 0 deletions
24
main.c
24
main.c
|
|
@ -45,6 +45,20 @@ fdm_sigint(struct fdm *fdm, int signo, void *data)
|
|||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
fdm_sigusr1_server(struct fdm *fdm, int signo, void *data)
|
||||
{
|
||||
server_hard_reload_config_colors(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
fdm_sigusr1_term(struct fdm *fdm, int signo, void *data)
|
||||
{
|
||||
term_hard_reload_config_colors(data);
|
||||
return true;
|
||||
}
|
||||
|
||||
static void
|
||||
print_usage(const char *prog_name)
|
||||
{
|
||||
|
|
@ -608,6 +622,15 @@ main(int argc, char *const *argv)
|
|||
goto out;
|
||||
}
|
||||
|
||||
bool ok = as_server ?
|
||||
fdm_signal_add(fdm, SIGUSR1, fdm_sigusr1_server, server)
|
||||
: fdm_signal_add(fdm, SIGUSR1, fdm_sigusr1_term, term);
|
||||
if (!ok) {
|
||||
LOG_WARN("failed to set SIGUSR1 handler");
|
||||
goto out;
|
||||
}
|
||||
LOG_INFO("added USR1 handler");
|
||||
|
||||
struct sigaction sig_ign = {.sa_handler = SIG_IGN};
|
||||
sigemptyset(&sig_ign.sa_mask);
|
||||
if (sigaction(SIGHUP, &sig_ign, NULL) < 0 ||
|
||||
|
|
@ -645,6 +668,7 @@ out:
|
|||
reaper_destroy(reaper);
|
||||
fdm_signal_del(fdm, SIGTERM);
|
||||
fdm_signal_del(fdm, SIGINT);
|
||||
fdm_signal_del(fdm, SIGUSR1);
|
||||
fdm_destroy(fdm);
|
||||
|
||||
config_free(&conf);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue