summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-01-26 19:14:08 +0100
committerLukas Fleischer <lfleischer@calcurse.org>2016-01-26 19:14:08 +0100
commitf0ec3247bc1b9cd857d3bb00cf8f85d965342f23 (patch)
treecdf9e2b5c90be80c3804a777fc7494f4816a728a /src
parent3dbfc7c1f5d9451dbf8fc37fc621c7cc80010214 (diff)
downloadcalcurse-f0ec3247bc1b9cd857d3bb00cf8f85d965342f23.tar.gz
calcurse-f0ec3247bc1b9cd857d3bb00cf8f85d965342f23.zip
Support SIGUSR1 in daemon mode
In commit 7f62fb1 (Let SIGUSR1 trigger a reload, 2014-10-10), we added support for reloading the data files by sending SIGUSR1 to an interactive calcurse process. Add the same functionality to the daemon mode. Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
Diffstat (limited to 'src')
-rw-r--r--src/dmon.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/dmon.c b/src/dmon.c
index a9c4ed8..913b9f9 100644
--- a/src/dmon.c
+++ b/src/dmon.c
@@ -66,6 +66,11 @@ static unsigned data_loaded;
static void dmon_sigs_hdlr(int sig)
{
+ if (sig == SIGUSR1) {
+ want_reload = 1;
+ return;
+ }
+
if (data_loaded)
free_user_data();
@@ -138,6 +143,7 @@ static unsigned daemonize(int status)
|| !sigs_set_hdlr(SIGTERM, dmon_sigs_hdlr)
|| !sigs_set_hdlr(SIGALRM, dmon_sigs_hdlr)
|| !sigs_set_hdlr(SIGQUIT, dmon_sigs_hdlr)
+ || !sigs_set_hdlr(SIGUSR1, dmon_sigs_hdlr)
|| !sigs_set_hdlr(SIGCHLD, SIG_IGN))
return 0;
@@ -172,6 +178,12 @@ void dmon_start(int parent_exit_status)
for (;;) {
int left;
+ if (want_reload) {
+ want_reload = 0;
+ io_reload_data();
+ notify_check_next_app(1);
+ }
+
if (!notify_get_next_bkgd())
DMON_ABRT(_("error loading next appointment\n"));