[PATCH] svstat: Account for file "ready"

From: Olivier Brunel <jjk_at_jjacky.com>
Date: Sun, 18 Jan 2015 21:09:12 +0100

Signed-off-by: Olivier Brunel <jjk_at_jjacky.com>
---
 src/supervision/s6-svstat.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff --git a/src/supervision/s6-svstat.c b/src/supervision/s6-svstat.c
index c986b8d..bc27c32 100644
--- a/src/supervision/s6-svstat.c
+++ b/src/supervision/s6-svstat.c
_at_@ -44,8 +44,20 @@ int main (int argc, char const *const *argv)
   isup = status.pid && !status.flagfinishing ;
   if (isup)
   {
+    struct stat st ;
+    unsigned int dirlen = str_len(*argv) ;
+    char fn[dirlen + 1 + sizeof(S6_SUPERVISE_READY_FILENAME)] ;
+    int ready ;
+    byte_copy(fn, dirlen, *argv) ;
+    byte_copy(fn + dirlen, 1, "/") ;
+    byte_copy(fn + dirlen + 1, sizeof(S6_SUPERVISE_READY_FILENAME), S6_SUPERVISE_READY_FILENAME) ;
+    if (stat(fn, &st) == -1)
+      if (errno != ENOENT) strerr_diefu2sys(111, "stat ", fn) ;
+      else ready = 0 ;
+    else ready = 1 ;
     buffer_putnoflush(buffer_1small,"up (pid ", 8) ;
     buffer_putnoflush(buffer_1small, fmt, uint_fmt(fmt, status.pid)) ;
+    if (ready) buffer_putnoflush(buffer_1small,"; ready", 7) ;
     buffer_putnoflush(buffer_1small, ") ", 2) ;
   }
   else buffer_putnoflush(buffer_1small, "down ", 5) ;
-- 
2.2.2
Received on Sun Jan 18 2015 - 20:09:12 UTC

This archive was generated by hypermail 2.3.0 : Sun May 09 2021 - 19:44:19 UTC