summary refs log tree commit diff
path: root/src/runsvdir.c
diff options
context:
space:
mode:
authorGerrit Pape <pape@smarden.org>2002-09-26 11:12:56 +0000
committerGerrit Pape <pape@smarden.org>2002-09-26 11:12:56 +0000
commit45fdf7fbeb4c43820779e6a8cc758b524e28af13 (patch)
treecd86fa7f3a22c2d1816e5d34b270850f677efe15 /src/runsvdir.c
parent728644c4e81a222f7b6920c28cb32d434a9506ff (diff)
downloadrunit-45fdf7fbeb4c43820779e6a8cc758b524e28af13.tar.gz
runit-45fdf7fbeb4c43820779e6a8cc758b524e28af13.tar.xz
runit-45fdf7fbeb4c43820779e6a8cc758b524e28af13.zip
cleanup. doc.
Diffstat (limited to 'src/runsvdir.c')
-rw-r--r--src/runsvdir.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/runsvdir.c b/src/runsvdir.c
index d9519db..bc6d22e 100644
--- a/src/runsvdir.c
+++ b/src/runsvdir.c
@@ -36,6 +36,7 @@ int loglen;
 int logpipe[2];
 iopause_fd io[1];
 struct taia stamplog;
+int exitsoon =0;
 
 void usage () {
   strerr_die4x(1, "usage: ", progname, USAGE, "\n");
@@ -49,6 +50,9 @@ void warn(char *m1, char *m2) {
 void warn3x(char *m1, char *m2, char *m3) {
   strerr_warn6("runsvdir ", svdir, ": warning: ", m1, m2, m3, 0);
 } 
+void s_term() {
+  exitsoon =1;
+}
 void runsv(int no, char *name) {
   int pid;
 
@@ -173,6 +177,7 @@ int main(int argc, char **argv) {
   progname =*argv++;
   if (! argv || ! *argv) usage();
 
+  sig_catch(sig_term, s_term);
   svdir =*argv++;
   if (argv && *argv) {
     log =*argv;
@@ -241,6 +246,12 @@ int main(int argc, char **argv) {
 	  }
 	}
       }
+    if (exitsoon) {
+      for (i =0; i < svnum; i++) {
+	if (sv[i].pid) kill(sv[i].pid, SIGTERM);
+      }
+      exit(0);
+    }
   }
   /* not reached */
   exit(0);