Download raw body.
fix logging during gotweb shutdown
During `rcctl stop gotwebd' a few potentially scary messages are logged,
as reported by xs on the IRC channel
gotwebd[46563]: lost child: pid 79956 exited abnormally
gotwebd[46563]: lost child: pid 98433 exited abnormally
gotwebd[46563]: gotwebd terminating
the sockets processes gets a SIGTERM and dies without handling, so the
parent process thinks it exited abnormally. Instead, catch SIGINT and
SIGTERM and handle them gracefully.
ok?
diff /home/op/w/got
commit - f9a64b14696fdd28e727956bd9c47f595f32f265
path + /home/op/w/got
blob - a0576465ae834d0f074a2d8dc1fbbb6ecec3186a
file + gotwebd/sockets.c
--- 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",
@@ -386,6 +390,10 @@ sockets_sighdlr(int sig, short event, void *arg)
break;
case SIGCHLD:
break;
+ case SIGINT:
+ case SIGTERM:
+ sockets_shutdown();
+ break;
default:
log_info("SIGNAL: %d", sig);
fatalx("unexpected signal");
@@ -412,6 +420,8 @@ sockets_shutdown(void)
free(srv);
free(gotwebd_env);
+
+ exit(0);
}
int
fix logging during gotweb shutdown