summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog2
-rw-r--r--package/CHANGES6
-rw-r--r--src/runit.c22
-rw-r--r--src/svwaitdown.c15
4 files changed, 33 insertions, 12 deletions
diff --git a/debian/changelog b/debian/changelog
index c03a197..c198209 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,7 +2,7 @@ runit (0.9.0-1) unstable; urgency=low
 
   * new upstream version.
 
- -- Gerrit Pape <pape@smarden.org>  Thu, 24 Apr 2003 13:11:57 +0200
+ -- Gerrit Pape <pape@smarden.org>  Thu, 24 Apr 2003 15:08:44 +0200
 
 runit (0.8.4-1) unstable; urgency=low
 
diff --git a/package/CHANGES b/package/CHANGES
index 97c8540..45cce57 100644
--- a/package/CHANGES
+++ b/package/CHANGES
@@ -1,10 +1,12 @@
 runit 0.9.0
-Thu, 24 Apr 2003 13:11:50 +0200
+Thu, 24 Apr 2003 15:08:26 +0200
   * runsvdir.c: don't propagate sig_term to runsv processes when receiving
     sig_term; send sig_term to all runsv processes and exit 111 when
     receiving sig_hangup.
+  * runit.c: print warning for each state that exits non-zero; restart
+    stage 2 if it exits non-zero.
   * svlogd.c: code cleanup.
-  * svwaitdown.c: send command "d" (and "x" if -x is set) to a service if
+  * svwaitdown.c: send command "d" (and "x" if -x is set) to each service if
     it's not in state 'want down'.
   * svwaitup.c: minor code cleanup.
   * man/runsvdir.8, man/svwaitdown.8: adapt.
diff --git a/src/runit.c b/src/runit.c
index 44534fb..5637d75 100644
--- a/src/runit.c
+++ b/src/runit.c
@@ -157,15 +157,19 @@ int main (int argc, const char * const *argv, char * const *envp) {
       }
 
       if (child == pid) {
-	if (wait_crashed(wstat)) {
-	  strerr_warn3(WARNING, "child crashed: ", stage[st], 0);
-          if (st == 0) {
-            /* this is stage 1 */
-            strerr_warn3(INFO, "leave stage: ", stage[st], 0);
-            strerr_warn2(WARNING, "skipping stage 2...", 0);
-            st++;
-            break;
-          }
+	if (wait_exitcode(wstat) != 0) {
+	  if (wait_crashed(wstat)) {
+	    strerr_warn3(WARNING, "child crashed: ", stage[st], 0);
+	    if (st == 0) {
+	      /* this is stage 1 */
+	      strerr_warn3(INFO, "leave stage: ", stage[st], 0);
+	      strerr_warn2(WARNING, "skipping stage 2...", 0);
+	      st++;
+	      break;
+	    }
+	  }
+	  else
+	    strerr_warn3(WARNING, "child failed: ", stage[st], 0);
 	  if (st == 1) {
 	    /* this is stage 2 */
 	    strerr_warn2(WARNING, "killing all processes in stage 2...", 0);
diff --git a/src/svwaitdown.c b/src/svwaitdown.c
index ec36e33..dfa748f 100644
--- a/src/svwaitdown.c
+++ b/src/svwaitdown.c
@@ -65,6 +65,19 @@ int main(int argc, const char * const *argv) {
   if (! argv || ! *argv) usage();
 
   dir =argv;
+  while (*dir) {
+    if ((fd =open_write("supervise/control")) == -1) {
+      dir++; /* bummer */
+      continue;
+    }
+    if (write(fd, "dx", 1 +doexit) != (1 +doexit)) {
+      close(fd); dir++; /* bummer */
+      continue;
+    }
+    close(fd);
+  }
+  dir =argv;
+
   tai_now(&start);
   while (*dir) {
     if (*dir[0] != '/') {
@@ -118,8 +131,10 @@ int main(int argc, const char * const *argv) {
       }
       if (write(fd, "dx", 1 +doexit) != (1 +doexit)) {
 	warn(*dir, ": unable to write to supervise/control: ", &strerr_sys);
+	close(fd);
 	continue;
       }
+      close(fd);
     }
   
     tai_now(&now);