summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorGerrit Pape <pape@smarden.org>2007-09-13 13:16:21 +0000
committerGerrit Pape <pape@smarden.org>2007-09-13 13:38:12 +0000
commit6ea9716f1fc13a976aad8af0ed3138c9bc6333d5 (patch)
treebe6efbf96c3a7d4d0ed6d7d6b188b6fe0511c5ab /src
parentf2ae55e8662d9a71e127da637584dff415c07e9f (diff)
downloadrunit-6ea9716f1fc13a976aad8af0ed3138c9bc6333d5.tar.gz
runit-6ea9716f1fc13a976aad8af0ed3138c9bc6333d5.tar.xz
runit-6ea9716f1fc13a976aad8af0ed3138c9bc6333d5.zip
sv.c: fix race on check for down if pid is 0 and state is run or finish.
Diffstat (limited to 'src')
-rw-r--r--src/sv.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/src/sv.c b/src/sv.c
index c8126a3..738a471 100644
--- a/src/sv.c
+++ b/src/sv.c
@@ -127,17 +127,16 @@ unsigned int svstatus_print(char *m) {
   pid <<=8; pid +=(unsigned char)svstatus[13];
   pid <<=8; pid +=(unsigned char)svstatus[12];
   tai_unpack(svstatus, &tstatus);
-  if (pid) {
     switch (svstatus[19]) {
+    case 0: outs(DOWN); break;
     case 1: outs(RUN); break;
     case 2: outs(FINISH); break;
     }
-    outs(m); outs(": (pid "); sulong[fmt_ulong(sulong, pid)] =0;
-    outs(sulong); outs(") ");
-  }
-  else {
-    outs(DOWN); outs(m); outs(": ");
-  }
+    outs(m); outs(": ");
+    if (svstatus[19]) {
+      outs("(pid "); sulong[fmt_ulong(sulong, pid)] =0;
+      outs(sulong); outs(") ");
+    }
   buffer_put(buffer_1, sulong,
     fmt_ulong(sulong, tnow.sec.x < tstatus.x ? 0 : tnow.sec.x -tstatus.x));
   outs("s");
@@ -220,7 +219,7 @@ int check(char *a) {
     if (!pid || svstatus[19] != 1) return(0);
     if (!checkscript()) return(0);
     break;
-  case 'd': if (pid) return(0); break;
+  case 'd': if (pid || svstatus[19] != 0) return(0); break;
     case 'C': if (pid) if (!checkscript()) return(0); break;
   case 't':
     case 'k':