diff options
author | Frederic Culot <calcurse@culot.org> | 2009-07-26 20:38:35 +0000 |
---|---|---|
committer | Frederic Culot <calcurse@culot.org> | 2009-07-26 20:38:35 +0000 |
commit | 279c564d2bb60747e56089658f66e848b7e88f55 (patch) | |
tree | 2e2ebfe0d40c6fa58ab9121164bce535614406a9 /src/dmon.c | |
parent | bccd37ef968dc07c2e3435123deba3e541662e0c (diff) | |
download | calcurse-279c564d2bb60747e56089658f66e848b7e88f55.zip |
Stop daemon when calcurse enters interactive mode.
Diffstat (limited to 'src/dmon.c')
-rw-r--r-- | src/dmon.c | 19 |
1 files changed, 18 insertions, 1 deletions
@@ -1,4 +1,4 @@ -/* $calcurse: dmon.c,v 1.3 2009/07/26 12:47:15 culot Exp $ */ +/* $calcurse: dmon.c,v 1.4 2009/07/26 20:38:36 culot Exp $ */ /* * Calcurse - text-based organizer @@ -180,3 +180,20 @@ dmon_start (int parent_exit_status) (void)io_fprintln (path_dmon_log, _("awakened at %s\n"), nowstr ()); } } + +/* + * Check if calcurse is running in background, and if yes, send a SIGINT + * signal to stop it. + */ +void +dmon_stop (void) +{ + int dpid; + + dpid = io_get_pid (path_dpid); + if (!dpid) + return; + + if (kill ((pid_t)dpid, SIGINT) < 0) + EXIT (_("Could not stop calcurse daemon: %s\n"), strerror (errno)); +} |