about summary refs log tree commit diff
path: root/src/supervision/s6-svc.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2015-06-25 19:17:43 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2015-06-25 19:17:43 +0000
commit49f1f9efe1874449303ca8c95a35a7b2bd4e13a0 (patch)
tree1d938071351c0447e96c250e4e999de0a687ba5b /src/supervision/s6-svc.c
parent96d70608d25da81038ac3bfb5273852f33e27504 (diff)
downloads6-49f1f9efe1874449303ca8c95a35a7b2bd4e13a0.tar.gz
s6-49f1f9efe1874449303ca8c95a35a7b2bd4e13a0.tar.xz
s6-49f1f9efe1874449303ca8c95a35a7b2bd4e13a0.zip
- doc fixes (changed mentions of s6-notifywhenup)
 - s6-svc -X
 - rc for 2.1.6.0
Diffstat (limited to 'src/supervision/s6-svc.c')
-rw-r--r--src/supervision/s6-svc.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c
index 7f3e538..f4eba63 100644
--- a/src/supervision/s6-svc.c
+++ b/src/supervision/s6-svc.c
@@ -1,5 +1,7 @@
 /* ISC license. */
 
+#include <unistd.h>
+#include <errno.h>
 #include <skalibs/uint.h>
 #include <skalibs/bytestr.h>
 #include <skalibs/sgetopt.h>
@@ -8,7 +10,7 @@
 #include <s6/config.h>
 #include <s6/s6-supervise.h>
 
-#define USAGE "s6-svc [ -D | -U ] [ -T timeout ] [ -abqhkti12pcoduxO ] servicedir"
+#define USAGE "s6-svc [ -D | -U ] [ -T timeout ] [ -abqhkti12pcoduxOX ] servicedir"
 #define dieusage() strerr_dieusage(100, USAGE)
 
 #define DATASIZE 63
@@ -24,7 +26,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
     subgetopt_t l = SUBGETOPT_ZERO ;
     for (;;)
     {
-      register int opt = subgetopt_r(argc, argv, "DUabqhkti12pcoduxOT:", &l) ;
+      register int opt = subgetopt_r(argc, argv, "DUabqhkti12pcoduxOXT:", &l) ;
       if (opt == -1) break ;
       switch (opt)
       {
@@ -46,6 +48,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
         case 'u' :
         case 'x' :
         case 'O' :
+        case 'X' :
         {
           if (datalen >= DATASIZE) strerr_dief1x(100, "too many commands") ;
           data[datalen++] = opt ;
@@ -59,6 +62,21 @@ int main (int argc, char const *const *argv, char const *const *envp)
   }
   if (!argc) dieusage() ;
   if (argc > 1) strerr_warn1x("ignoring extra arguments") ;
+
+  if (updown[1] == 'U')
+  {
+    unsigned int arglen = str_len(argv[0]) ;
+    char fn[arglen + 17] ;
+    byte_copy(fn, arglen, argv[0]) ;
+    byte_copy(fn + arglen, 17, "/notification-fd") ;
+    if (access(fn, F_OK) < 0)
+    {
+      if (errno != ENOENT) strerr_diefu2sys(111, "access ", fn) ;
+      updown[1] = 0 ;
+      strerr_warnw2x(fn, "not present - ignoring -U option") ;
+    }
+  }
+
   if (updown[1])
   {
     char const *newargv[11] ;