summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/fmt_ptime.c12
-rw-r--r--src/fmt_ptime.h1
-rw-r--r--src/runsv.c16
-rw-r--r--src/svlogd.c14
4 files changed, 29 insertions, 14 deletions
diff --git a/src/fmt_ptime.c b/src/fmt_ptime.c
index 7c8adce..e538b35 100644
--- a/src/fmt_ptime.c
+++ b/src/fmt_ptime.c
@@ -2,7 +2,7 @@
 #include "fmt_ptime.h"
 #include "fmt.h"
 
-unsigned int fmt_ptime(char *s, struct taia *ta) {
+unsigned int fmt_ptime2(char *s, struct taia *ta, char sep) {
   struct tm *t;
   unsigned long u;
 
@@ -12,13 +12,21 @@ unsigned int fmt_ptime(char *s, struct taia *ta) {
   fmt_ulong(s, 1900 +t->tm_year);
   s[4] ='-'; fmt_uint0(&s[5], t->tm_mon +1, 2);
   s[7] ='-'; fmt_uint0(&s[8], t->tm_mday, 2);
-  s[10] ='_'; fmt_uint0(&s[11], t->tm_hour, 2);
+  s[10] =sep; fmt_uint0(&s[11], t->tm_hour, 2);
   s[13] =':'; fmt_uint0(&s[14], t->tm_min, 2);
   s[16] =':'; fmt_uint0(&s[17], t->tm_sec, 2);
   s[19] ='.'; fmt_uint0(&s[20], ta->nano, 9);
   return(25);
 }
 
+unsigned int fmt_ptime(char *s, struct taia *ta) {
+  return(fmt_ptime2(s, ta, '_'));
+}
+
+unsigned int fmt_ptime_iso8601(char *s, struct taia *ta) {
+  return(fmt_ptime2(s, ta, 'T'));
+}
+
 unsigned int fmt_taia(char *s, struct taia *t) {
   static char hex[16] ="0123456789abcdef";
   static char pack[TAIA_PACK];
diff --git a/src/fmt_ptime.h b/src/fmt_ptime.h
index fe027b8..72ea008 100644
--- a/src/fmt_ptime.h
+++ b/src/fmt_ptime.h
@@ -8,6 +8,7 @@
 #include "taia.h"
 
 extern unsigned int fmt_ptime(char *, struct taia *);
+extern unsigned int fmt_ptime_iso8601(char *, struct taia *);
 extern unsigned int fmt_taia(char *, struct taia *);
 
 #endif
diff --git a/src/runsv.c b/src/runsv.c
index 655ce12..db36422 100644
--- a/src/runsv.c
+++ b/src/runsv.c
@@ -46,6 +46,7 @@ struct svdir {
   int ctrl;
   int want;
   struct taia start;
+  int wstat;
   int fdlock;
   int fdcontrol;
   int fdcontrolwrite;
@@ -260,15 +261,23 @@ void stopservice(struct svdir *s) {
 
 void startservice(struct svdir *s) {
   int p;
-  char *run[2];
+  char *run[4];
+  char code[FMT_ULONG];
+  char stat[FMT_ULONG];
 
-  if (s->state == S_FINISH)
+  if (s->state == S_FINISH) {
     run[0] ="./finish";
+    code[fmt_ulong(code, wait_exitcode(s->wstat))] =0;
+    run[1] =wait_crashed(s->wstat) ? "-1" : code;
+    stat[fmt_ulong(stat, s->wstat & 0xff)] =0;
+    run[2] =stat;
+    run[3] =0;
+  }
   else {
     run[0] ="./run";
     custom(s, 'u');
+    run[1] =0;
   }
-  run[1] =0;
 
   if (s->pid != 0) stopservice(s); /* should never happen */
   while ((p =fork()) == -1) {
@@ -539,6 +548,7 @@ int main(int argc, char **argv) {
       if (child == svd[0].pid) {
         svd[0].pid =0;
         pidchanged =1;
+        svd[0].wstat =wstat;
         svd[0].ctrl &=~C_TERM;
         if (svd[0].state != S_FINISH)
           if ((fd =open_read("finish")) != -1) {
diff --git a/src/svlogd.c b/src/svlogd.c
index e7f2eff..b267b70 100644
--- a/src/svlogd.c
+++ b/src/svlogd.c
@@ -694,7 +694,7 @@ int main(int argc, const char **argv) {
       if (buflen == 0) buflen =1024;
       break;
     case 't':
-      if (++timestamp > 2) timestamp =2;
+      if (++timestamp > 3) timestamp =3;
       break;
     case 'v':
       ++verbose;
@@ -752,15 +752,11 @@ int main(int argc, const char **argv) {
       if (! linelen && timestamp) {
         taia_now(&now);
         switch (timestamp) {
-        case 1:
-          stamp[fmt_taia(stamp, &now)] =' ';
-          stamp[26] =0;
-          break;
-        case 2:
-          stamp[fmt_ptime(stamp, &now)] =' ';
-          stamp[26] =0;
-          break;
+        case 1: fmt_taia(stamp, &now); break;
+        case 2: fmt_ptime(stamp, &now); break;
+        case 3: fmt_ptime_iso8601(stamp, &now); break;
         }
+	stamp[25] =' '; stamp[26] =0;
       }
       if (ch == '\n') break;
       if (repl) {