summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorFrederic Culot <calcurse@culot.org>2009-08-09 15:49:57 +0000
committerFrederic Culot <calcurse@culot.org>2009-08-09 15:49:57 +0000
commit4db3b69b277a5cc39b6f826fc06bb2e1781c8b70 (patch)
treee87dd3506c10c9e1af75c6245926d4dc3583c3f0 /src
parent3c9d6c13cc0d65d4d439288a11b5e683ac151db6 (diff)
downloadcalcurse-4db3b69b277a5cc39b6f826fc06bb2e1781c8b70.zip
Remove calcurse lock file when running in interactive mode and SIGTERM is received.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/sigs.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/sigs.c b/src/sigs.c
index 6f341e7..bfe6ee1 100755
--- a/src/sigs.c
+++ b/src/sigs.c
@@ -1,4 +1,4 @@
-/* $calcurse: sigs.c,v 1.9 2009/07/19 16:51:36 culot Exp $ */
+/* $calcurse: sigs.c,v 1.10 2009/08/09 15:49:58 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -38,6 +38,7 @@
#include <sys/types.h>
#include <sys/wait.h>
+#include <unistd.h>
#include <errno.h>
#include <string.h>
@@ -64,6 +65,14 @@ generic_hdlr (int sig)
clearok (curscr, TRUE);
(void)ungetch (KEY_RESIZE);
break;
+ case SIGTERM:
+ if (unlink (path_cpid) != 0)
+ {
+ EXIT (_("Could not remove calcurse lock file: %s\n"),
+ strerror (errno));
+ }
+ exit (EXIT_SUCCESS);
+ break;
}
}
@@ -92,6 +101,7 @@ sigs_init ()
{
if (!sigs_set_hdlr (SIGCHLD, generic_hdlr)
|| !sigs_set_hdlr (SIGWINCH, generic_hdlr)
+ || !sigs_set_hdlr (SIGTERM, generic_hdlr)
|| !sigs_set_hdlr (SIGINT, SIG_IGN))
exit_calcurse (1);
}