summary refs log tree commit diff
diff options
context:
space:
mode:
authorLeah Neukirchen <leah@vuxu.org>2022-01-28 15:18:01 +0100
committerLeah Neukirchen <leah@vuxu.org>2022-01-28 15:18:01 +0100
commitd18c05f88e28762ae284b4a856cf03c3955eb6b7 (patch)
tree6be1ee16b19d35c3d2579c1d11695fe4706ca85e
parentca41090aaf4ffb25e87ed073990fe91cb18179ee (diff)
downloadrvnit-d18c05f88e28762ae284b4a856cf03c3955eb6b7.tar.gz
rvnit-d18c05f88e28762ae284b4a856cf03c3955eb6b7.tar.xz
rvnit-d18c05f88e28762ae284b4a856cf03c3955eb6b7.zip
close writing pipe end after oneshots finish
-rw-r--r--rvnit.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/rvnit.c b/rvnit.c
index 816b6f9..f070ddd 100644
--- a/rvnit.c
+++ b/rvnit.c
@@ -182,6 +182,14 @@ restart(int i)
 	}
 }
 
+void
+cleanup(int i)
+{
+	/* for oneshots, we don't need the pipe after exit */
+	if (services[i].logfd[1] > 0)
+		close(services[i].logfd[1]);
+}
+
 int
 charsig(char c)
 {
@@ -820,7 +828,7 @@ main(int argc, char *argv[])
 						goto fatal;
 					}
 				}
-
+				cleanup(i);
 				oneshot--;
 			} else if (services[i].name[2] == 'D' ||
 			    services[i].name[2] == 'G' ||
@@ -985,6 +993,7 @@ fatal:		; // arrives with level < 99
 
 			if (services[i].name[2] == 'K') {
 				LOG("oneshot %s exited with status %d", services[i].name, services[i].status);
+				cleanup(i);
 				oneshot--;
 			} else if (services[i].name[2] == 'D') {
 				LOG("daemon %s exited with status %d", services[i].name, services[i].status);