[hackers] [quark] Refactor sighandler || FRIGN

From: <git_AT_suckless.org>
Date: Thu, 07 Aug 2014 17:24:16 +0200

commit a345c63a597f5db618bf79c23ca4e6277eeab33e
Author: FRIGN <dev_AT_frign.de>
Date: Thu Aug 7 17:24:39 2014 +0200

    Refactor sighandler
    
    You can't handle SIGKILL. Given we have control over which
    signals are passed to the sighandler, it's enough to catch SIGCHLD
    and do standard behaviour than building a big switch for that.

diff --git a/quark.c b/quark.c
index d819e8d..72b135b 100644
--- a/quark.c
+++ b/quark.c
_AT_@ -459,20 +459,12 @@ serve(int fd) {
 
 void
 sighandler(int sig) {
- switch(sig) {
- default: break;
- case SIGHUP:
- case SIGINT:
- case SIGQUIT:
- case SIGABRT:
- case SIGTERM:
+ if (sig == SIGCHLD) {
+ while(0 < waitpid(-1, NULL, WNOHANG));
+ } else {
                 logerrmsg("received signal: %s, closing down
", strsignal(sig));
                 close(fd);
                 running = 0;
- break;
- case SIGCHLD:
- while(0 < waitpid(-1, NULL, WNOHANG));
- break;
         }
 }
 
_AT_@ -514,7 +506,6 @@ main(int argc, char *argv[]) {
         signal(SIGQUIT, sighandler);
         signal(SIGABRT, sighandler);
         signal(SIGTERM, sighandler);
- signal(SIGKILL, sighandler);
 
         /* init */
         setbuf(stdout, NULL); /* unbuffered stdout */
Received on Thu Aug 07 2014 - 17:24:16 CEST

This archive was generated by hypermail 2.3.0 : Thu Aug 07 2014 - 17:36:08 CEST