Do not start the daemon more than once

Avoid starting multiple daemon instances if the --daemon argument is
passed and the daemon is already running. Terminate the already running
instance before spawning a new one instead.

Suggested-by: Vlad Glagolev <scm@vaygr.net>
Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer 2016-10-19 18:17:08 +02:00
parent 095576b945
commit 0d74c14fd1
3 changed files with 4 additions and 3 deletions

View File

@ -97,7 +97,7 @@ today, tomorrow, and the day after tomorrow. The first form is equivalent to
appointments can be specified using the *-c* flag.
*--daemon*::
Start calcurse in background mode.
Start calcurse in background mode. Restart if the daemon was already running.
*--days* <num>::
Specify the length of the range (in days) when used with *-Q*. Cannot be

View File

@ -201,8 +201,8 @@ Note: as for the `-a` flag, the calendar from which to read the appointments
can be specified using the `-c` flag.
`--daemon`::
Start calcurse in background mode. See <<basics_daemon,Background mode>> for
details.
Start calcurse in background mode. Restart if the daemon was already running.
See <<basics_daemon,Background mode>> for details.
`--days <num>`::
Specify the length of the range (in days) when used with `-Q`. Cannot be

View File

@ -803,6 +803,7 @@ int parse_args(int argc, char **argv)
io_export_data(xfmt, export_uid);
} else if (daemon) {
notify_init_vars();
dmon_stop();
dmon_start(0);
} else {
/* interactive mode */