Commit Diff


commit - 2fbb00a4292fb45faa409c8983136a105cbda7ba
commit + 736fac9082f40fedb3e0fe65f715dc403eb7b250
blob - a0576465ae834d0f074a2d8dc1fbbb6ecec3186a
blob + 156dad3dc6bd9624457ed102668c97c9f301eda3
--- 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