Commit Diff


commit - 53f578a6d94eeb340775f5e05c24fb9a5df33236
commit + 7a4d2c244110a34fed1abc76faa9824c417d83dc
blob - c2397c84d7c5b27ebd5bbaf41e79d15f5d275a82
blob + e69a8e9f0c23d323ad013f7751187f5a401d5fa1
--- gotwebd/sockets.c
+++ gotwebd/sockets.c
@@ -88,7 +88,7 @@ int cgi_inflight = 0;
 void
 sockets(struct gotwebd *env, int fd)
 {
-	struct event	 sighup, sigusr1, sigchld;
+	struct event	 sighup, sigint, sigusr1, sigchld, sigterm;
 
 	event_init();
 
@@ -110,10 +110,14 @@ sockets(struct gotwebd *env, int fd)
 
 	signal_set(&sighup, SIGHUP, sockets_sighdlr, env);
 	signal_add(&sighup, NULL);
+	signal_set(&sigint, SIGINT, sockets_sighdlr, env);
+	signal_add(&sigint, NULL);
 	signal_set(&sigusr1, SIGUSR1, sockets_sighdlr, env);
 	signal_add(&sigusr1, NULL);
 	signal_set(&sigchld, SIGCHLD, sockets_sighdlr, env);
 	signal_add(&sigchld, NULL);
+	signal_set(&sigterm, SIGTERM, sockets_sighdlr, env);
+	signal_add(&sigterm, NULL);
 
 #ifndef PROFILE
 	if (pledge("stdio rpath inet recvfd proc exec sendfd unveil",
@@ -385,6 +389,10 @@ sockets_sighdlr(int sig, short event, void *arg)
 		log_info("%s: ignoring SIGUSR1", __func__);
 		break;
 	case SIGCHLD:
+		break;
+	case SIGINT:
+	case SIGTERM:
+		sockets_shutdown();
 		break;
 	default:
 		log_info("SIGNAL: %d", sig);
@@ -412,6 +420,8 @@ sockets_shutdown(void)
 		free(srv);
 
 	free(gotwebd_env);
+
+	exit(0);
 }
 
 int