"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Mark Jamsek <mark@jamsek.com>
Subject:
Re: fix logging during gotweb shutdown
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Sun, 11 Feb 2024 01:36:55 +1100

Download raw body.

Thread
Omar Polo <op@omarpolo.com> wrote:
> 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?

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


-- 
Mark Jamsek <https://bsdbox.org>
GPG: F2FF 13DE 6A06 C471 CA80  E6E2 2930 DC66 86EE CF68