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.
This commit is contained in:
parent
92b8bc27da
commit
a345c63a59
1 changed files with 3 additions and 12 deletions
15
quark.c
15
quark.c
|
@ -459,20 +459,12 @@ serve(int fd) {
|
||||||
|
|
||||||
void
|
void
|
||||||
sighandler(int sig) {
|
sighandler(int sig) {
|
||||||
switch(sig) {
|
if (sig == SIGCHLD) {
|
||||||
default: break;
|
while(0 < waitpid(-1, NULL, WNOHANG));
|
||||||
case SIGHUP:
|
} else {
|
||||||
case SIGINT:
|
|
||||||
case SIGQUIT:
|
|
||||||
case SIGABRT:
|
|
||||||
case SIGTERM:
|
|
||||||
logerrmsg("received signal: %s, closing down\n", strsignal(sig));
|
logerrmsg("received signal: %s, closing down\n", strsignal(sig));
|
||||||
close(fd);
|
close(fd);
|
||||||
running = 0;
|
running = 0;
|
||||||
break;
|
|
||||||
case SIGCHLD:
|
|
||||||
while(0 < waitpid(-1, NULL, WNOHANG));
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -514,7 +506,6 @@ main(int argc, char *argv[]) {
|
||||||
signal(SIGQUIT, sighandler);
|
signal(SIGQUIT, sighandler);
|
||||||
signal(SIGABRT, sighandler);
|
signal(SIGABRT, sighandler);
|
||||||
signal(SIGTERM, sighandler);
|
signal(SIGTERM, sighandler);
|
||||||
signal(SIGKILL, sighandler);
|
|
||||||
|
|
||||||
/* init */
|
/* init */
|
||||||
setbuf(stdout, NULL); /* unbuffered stdout */
|
setbuf(stdout, NULL); /* unbuffered stdout */
|
||||||
|
|
Loading…
Reference in a new issue