summaryrefslogtreecommitdiff
path: root/src/sigs.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2013-04-13 23:31:06 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2013-04-14 00:19:01 +0200
commit694d28eb78dfad98e2e7ea670d93a153d8efd368 (patch)
tree485dc11d3644d9dadb5fd4d67c5ef8103be79623 /src/sigs.c
parent9907069f442c56c90b67accb2d8fbd046dfce6db (diff)
downloadcalcurse-694d28eb78dfad98e2e7ea670d93a153d8efd368.zip
Use tabs instead of spaces for indentation
This completes our switch to the Linux kernel coding style. Note that we still use deeply nested constructs at some places which need to be fixed up later. Converted using the `Lindent` script from the Linux kernel code base, along with some manual fixes. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/sigs.c')
-rw-r--r--src/sigs.c72
1 files changed, 37 insertions, 35 deletions
diff --git a/src/sigs.c b/src/sigs.c
index 68dcdfd..e746a01 100644
--- a/src/sigs.c
+++ b/src/sigs.c
@@ -65,60 +65,62 @@
*/
static void generic_hdlr(int sig)
{
- switch (sig) {
- case SIGCHLD:
- while (waitpid(WAIT_MYPGRP, NULL, WNOHANG) > 0) ;
- break;
- case SIGWINCH:
- resize = 1;
- clearok(curscr, TRUE);
- 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;
- }
+ switch (sig) {
+ case SIGCHLD:
+ while (waitpid(WAIT_MYPGRP, NULL, WNOHANG) > 0) ;
+ break;
+ case SIGWINCH:
+ resize = 1;
+ clearok(curscr, TRUE);
+ 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;
+ }
}
unsigned sigs_set_hdlr(int sig, void (*handler) (int))
{
- struct sigaction sa;
+ struct sigaction sa;
- memset(&sa, 0, sizeof sa);
- sigemptyset(&sa.sa_mask);
- sa.sa_handler = handler;
- sa.sa_flags = 0;
- if (sigaction(sig, &sa, NULL) == -1) {
- ERROR_MSG(_("Error setting signal #%d : %s\n"), sig, strerror(errno));
- return 0;
- }
+ memset(&sa, 0, sizeof sa);
+ sigemptyset(&sa.sa_mask);
+ sa.sa_handler = handler;
+ sa.sa_flags = 0;
+ if (sigaction(sig, &sa, NULL) == -1) {
+ ERROR_MSG(_("Error setting signal #%d : %s\n"), sig,
+ strerror(errno));
+ return 0;
+ }
- return 1;
+ return 1;
}
/* Signal handling init. */
void 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);
+ 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);
}
/* Ignore SIGWINCH and SIGTERM signals. */
void sigs_ignore(void)
{
- sigs_set_hdlr(SIGWINCH, SIG_IGN);
- sigs_set_hdlr(SIGTERM, SIG_IGN);
+ sigs_set_hdlr(SIGWINCH, SIG_IGN);
+ sigs_set_hdlr(SIGTERM, SIG_IGN);
}
/* No longer ignore SIGWINCH and SIGTERM signals. */
void sigs_unignore(void)
{
- sigs_set_hdlr(SIGWINCH, generic_hdlr);
- sigs_set_hdlr(SIGTERM, generic_hdlr);
+ sigs_set_hdlr(SIGWINCH, generic_hdlr);
+ sigs_set_hdlr(SIGTERM, generic_hdlr);
}