summaryrefslogtreecommitdiff
path: root/src/sigs.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2012-05-21 10:13:05 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2012-05-21 10:13:05 +0200
commitcfd8ede2b3c7248bd3b78e71ef17bdc9eb819aae (patch)
tree1ba7b4f15c9a36cd5d9aab803ed4e9defb8222d2 /src/sigs.c
parent47c52ae7bbfec87a80fb583fb0753b4d77b0ba1d (diff)
downloadcalcurse-cfd8ede2b3c7248bd3b78e71ef17bdc9eb819aae.zip
Switch to Linux kernel coding style
Convert our code base to adhere to Linux kernel coding style using Lindent, with the following exceptions: * Use spaces, instead of tabs, for indentation. * Use 2-character indentations (instead of 8 characters). Rationale: We currently have too much levels of indentation. Using 8-character tabs would make huge code parts unreadable. These need to be cleaned up before we can switch to 8 characters. Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/sigs.c')
-rw-r--r--src/sigs.c67
1 files changed, 29 insertions, 38 deletions
diff --git a/src/sigs.c b/src/sigs.c
index f74ba7b..4f5d982 100644
--- a/src/sigs.c
+++ b/src/sigs.c
@@ -53,57 +53,48 @@
* This is needed to avoid zombie processes running on system.
* Also catch CTRL-C (SIGINT), and SIGWINCH to resize screen automatically.
*/
-static void
-generic_hdlr (int sig)
+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))
+unsigned sigs_set_hdlr(int sig, void (*handler) (int))
{
struct sigaction sa;
- memset (&sa, 0, sizeof sa);
- sigemptyset (&sa.sa_mask);
+ 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;
- }
+ if (sigaction(sig, &sa, NULL) == -1) {
+ ERROR_MSG(_("Error setting signal #%d : %s\n"), sig, strerror(errno));
+ return 0;
+ }
return 1;
}
/* Signal handling init. */
-void
-sigs_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);
}