summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2023-10-08 14:42:48 -0400
committerJune McEnroe <june@causal.agency>2023-10-08 14:42:48 -0400
commitd3c5af429c5ac1712c50645f85db1a31c6261d4d (patch)
treead883b9ba99df8e54b49d084376eb704356e1207
parentDon't put the child PID in proctitle (diff)
downloadkitd-d3c5af429c5ac1712c50645f85db1a31c6261d4d.tar.gz
kitd-d3c5af429c5ac1712c50645f85db1a31c6261d4d.zip
Don't treat SIGHUP specially
If you want to restart the child, just restart kitd.
Diffstat (limited to '')
-rw-r--r--kitd.88
-rw-r--r--kitd.c41
2 files changed, 23 insertions, 26 deletions
diff --git a/kitd.8 b/kitd.8
index c88c97a..f0c2672 100644
--- a/kitd.8
+++ b/kitd.8
@@ -1,4 +1,4 @@
-.Dd October  7, 2023
+.Dd October  8, 2023
 .Dt KITD 8
 .Os
 .
@@ -59,10 +59,6 @@ The default interval is 1 second.
 .Nm
 responds to the following signals:
 .Bl -tag -width Ds
-.It Dv SIGHUP
-The child process is sent
-.Dv SIGTERM
-and restarted.
 .It Dv SIGTERM , Dv SIGINT
 The signal is forwarded to
 the child process.
@@ -71,7 +67,7 @@ exits.
 .It Dv SIGINFO
 The status of the child process
 is logged.
-.It Dv SIGUSR1 , Dv SIGUSR2
+.It Dv SIGHUP , Dv SIGUSR1 , Dv SIGUSR2
 The signal is forwarded to
 the child process.
 .El
diff --git a/kitd.c b/kitd.c
index 4e5f518..f936e3f 100644
--- a/kitd.c
+++ b/kitd.c
@@ -174,23 +174,6 @@ int main(int argc, char *argv[]) {
 	struct Line stderrBuffer = {0};
 
 	for (;;) {
-		if (signals[SIGHUP]) {
-			interval = restart;
-			if (child) killpg(child, SIGTERM);
-			signals[SIGHUP] = 0;
-		}
-
-		if (signals[SIGINT] || signals[SIGTERM]) {
-			stop = true;
-			int sig = (signals[SIGINT] ? SIGINT : SIGTERM);
-			if (child) {
-				killpg(child, sig);
-			} else {
-				break;
-			}
-			signals[sig] = 0;
-		}
-
 		if (signals[SIGINFO]) {
 			clock_gettime(CLOCK_MONOTONIC, &now);
 			if (child) {
@@ -203,9 +186,27 @@ int main(int argc, char *argv[]) {
 			signals[SIGINFO] = 0;
 		}
 
-		if (signals[SIGUSR1] || signals[SIGUSR2]) {
-			int sig = (signals[SIGUSR1] ? SIGUSR1 : SIGUSR2);
-			if (child) killpg(child, sig);
+		if (signals[SIGHUP]) {
+			if (child) killpg(child, SIGHUP);
+			signals[SIGHUP] = 0;
+		}
+		if (signals[SIGUSR1]) {
+			if (child) killpg(child, SIGUSR1);
+			signals[SIGUSR1] = 0;
+		}
+		if (signals[SIGUSR2]) {
+			if (child) killpg(child, SIGUSR2);
+			signals[SIGUSR2] = 0;
+		}
+
+		if (signals[SIGINT] || signals[SIGTERM]) {
+			stop = true;
+			int sig = (signals[SIGINT] ? SIGINT : SIGTERM);
+			if (child) {
+				killpg(child, sig);
+			} else {
+				break;
+			}
 			signals[sig] = 0;
 		}