Commit Diff


commit - 60b4efa1e2df8b5465deaec5c5493e1b2bf6a6c4
commit + 3bda540e3428e7e3a18ee1c54a65c449ca10f35e
blob - a7913977135f8b81d16a9144205e77daf0d64960
blob + 938c4162b15d1300f160a253795e33b91af35f2d
--- gmid.8
+++ gmid.8
@@ -32,7 +32,9 @@ talk to FastCGI applications and act as a gemini rever
 .Pp
 .Nm
 rereads the configuration file when it receives
-.Dv SIGHUP .
+.Dv SIGHUP
+and reopens log files when it receives
+.Dv SIGUSR1 .
 .Pp
 The options are as follows:
 .Bl -tag -width 14m
blob - 6a7132c19fdb68aaecf8d099ef114d99e1c5b41c
blob + d8f4e760eac8db95d28e22fb90db884ade255aea
--- gmid.c
+++ gmid.c
@@ -299,11 +299,13 @@ main(int argc, char **argv)
 	signal_set(&ps->ps_evsigterm, SIGTERM, main_sig_handler, ps);
 	signal_set(&ps->ps_evsigchld, SIGCHLD, main_sig_handler, ps);
 	signal_set(&ps->ps_evsighup, SIGHUP, main_sig_handler, ps);
+	signal_set(&ps->ps_evsigusr1, SIGUSR1, main_sig_handler, ps);
 
 	signal_add(&ps->ps_evsigint, NULL);
 	signal_add(&ps->ps_evsigterm, NULL);
 	signal_add(&ps->ps_evsigchld, NULL);
 	signal_add(&ps->ps_evsighup, NULL);
+	signal_add(&ps->ps_evsigusr1, NULL);
 
 	proc_connect(ps);
 
@@ -317,20 +319,33 @@ main(int argc, char **argv)
 }
 
 static int
-main_configure(struct conf *conf)
+main_send_logfd(struct conf *conf)
 {
 	struct privsep	*ps = conf->ps;
-	int fd = -1;
+	int		 fd = -1;
 
-	if (!debug) {
-		if (conf->log_access && (fd = open(conf->log_access,
-		    O_WRONLY|O_CREAT|O_APPEND, 0600)) == -1)
-			log_warn("can't open %s", conf->log_access);
-		if (proc_compose_imsg(ps, PROC_LOGGER, -1, IMSG_LOG_TYPE,
-		    -1, fd, NULL, 0) == -1)
-			return -1;
+	if (debug)
+		return 0;
+
+	if (conf->log_access) {
+		fd = open(conf->log_access, O_WRONLY|O_CREAT|O_APPEND, 0600);
+		if (fd == -1)
+			log_warn("can't open %s", conf->log_access);
 	}
+	if (proc_compose_imsg(ps, PROC_LOGGER, -1, IMSG_LOG_TYPE, -1, fd,
+	    NULL, 0) == -1)
+		return -1;
+	return 0;
+}
 
+static int
+main_configure(struct conf *conf)
+{
+	struct privsep	*ps = conf->ps;
+
+	if (main_send_logfd(conf) == -1)
+		return -1;
+
 	conf->reload = conf->prefork + 1; /* servers, crypto */
 
 	if (proc_compose(ps, PROC_SERVER, IMSG_RECONF_START, NULL, 0) == -1)
@@ -405,6 +420,9 @@ main_sig_handler(int sig, short ev, void *arg)
 	case SIGINT:
 		main_shutdown(ps->ps_env);
 		break;
+	case SIGUSR1:
+		main_send_logfd(ps->ps_env);
+		break;
 	default:
 		fatalx("unexpected signal %d", sig);
 	}
blob - f0def37e0aa277ee96bb187dcd22055aa343b7ff
blob + 45b5216145464d29159c846e6982302fb843a1e6
--- proc.h
+++ proc.h
@@ -68,6 +68,7 @@ struct privsep {
 	struct event			 ps_evsigterm;
 	struct event			 ps_evsigchld;
 	struct event			 ps_evsighup;
+	struct event			 ps_evsigusr1;
 
 	void				*ps_env;
 };