summary refs log tree commit diff
diff options
context:
space:
mode:
-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);