summaryrefslogtreecommitdiff
path: root/src/supervision
diff options
context:
space:
mode:
Diffstat (limited to 'src/supervision')
-rw-r--r--src/supervision/s6-notifyoncheck.c9
-rw-r--r--src/supervision/s6-permafailon.c6
-rw-r--r--src/supervision/s6-svc.c10
-rw-r--r--src/supervision/s6-svscan.c30
4 files changed, 23 insertions, 32 deletions
diff --git a/src/supervision/s6-notifyoncheck.c b/src/supervision/s6-notifyoncheck.c
index b1ef96b..a1ec7ff 100644
--- a/src/supervision/s6-notifyoncheck.c
+++ b/src/supervision/s6-notifyoncheck.c
@@ -16,6 +16,7 @@
#include <skalibs/djbunix.h>
#include <skalibs/selfpipe.h>
#include <skalibs/iopause.h>
+#include <skalibs/exec.h>
#include <s6/s6.h>
@@ -176,7 +177,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
*/
- if (pipe(p) < 0) strerr_diefu1sys(111, "pipe") ;
+ if (pipecoe(p) < 0) strerr_diefu1sys(111, "pipe") ;
switch (df ? doublefork() : fork())
{
case -1: strerr_diefu1sys(111, df ? "doublefork" : "fork") ;
@@ -185,10 +186,8 @@ int main (int argc, char const *const *argv, char const *const *envp)
{
char c ;
close((int)fd) ;
- close(p[1]) ;
if (read(p[0], &c, 1) < 1) strerr_diefu1x(111, "synchronize with child") ;
- close(p[0]) ;
- xpathexec_run(argv[0], argv, envp) ;
+ xexec_e(argv, envp) ;
}
}
@@ -206,7 +205,7 @@ int main (int argc, char const *const *argv, char const *const *envp)
x[1].fd = ftrigr_fd(&a) ;
if (fd_write(p[1], "", 1) < 1) strerr_diefu1sys(2, "synchronize with parent") ;
- fd_close(p[1]) ;
+ close(p[1]) ;
/* Loop around a sleep and a ./data/check invocation */
diff --git a/src/supervision/s6-permafailon.c b/src/supervision/s6-permafailon.c
index 1a9d68e..3912691 100644
--- a/src/supervision/s6-permafailon.c
+++ b/src/supervision/s6-permafailon.c
@@ -9,7 +9,7 @@
#include <skalibs/bitarray.h>
#include <skalibs/sig.h>
#include <skalibs/tai.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
#include <s6/s6-supervise.h>
@@ -59,7 +59,7 @@ static inline void list_scan (char const *s, unsigned char *codes, sigset_t *sig
}
}
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
unsigned char codes[32] ;
sigset_t sigs ;
@@ -122,5 +122,5 @@ int main (int argc, char const *const *argv, char const *const *envp)
}
cont:
- xpathexec0_run(argv + 4, envp) ;
+ xexec0(argv+4) ;
}
diff --git a/src/supervision/s6-svc.c b/src/supervision/s6-svc.c
index 6a5d64b..3e024d6 100644
--- a/src/supervision/s6-svc.c
+++ b/src/supervision/s6-svc.c
@@ -3,10 +3,12 @@
#include <string.h>
#include <unistd.h>
#include <errno.h>
+
#include <skalibs/types.h>
#include <skalibs/sgetopt.h>
#include <skalibs/strerr2.h>
-#include <skalibs/djbunix.h>
+#include <skalibs/exec.h>
+
#include <s6/config.h>
#include <s6/s6-supervise.h>
@@ -15,7 +17,7 @@
#define DATASIZE 63
-int main (int argc, char const *const *argv, char const *const *envp)
+int main (int argc, char const *const *argv)
{
char data[DATASIZE+1] = "-" ;
unsigned int datalen = 1 ;
@@ -106,12 +108,12 @@ int main (int argc, char const *const *argv, char const *const *envp)
newargv[m++] = argv[0] ;
}
newargv[m++] = 0 ;
- xpathexec_run(newargv[0], newargv, envp) ;
+ xexec(newargv) ;
}
else switch (s6_svc_writectl(argv[0], S6_SUPERVISE_CTLDIR, data + 1, datalen - 1))
{
case -1 : strerr_diefu2sys(111, "control ", argv[0]) ;
- case -2 : strerr_dief3sys(100, "something is wrong with the ", argv[0], "/" S6_SUPERVISE_CTLDIR " directory. errno reported") ;
+ case -2 : strerr_dief3sys(100, "something is wrong with the ", argv[0], "/" S6_SUPERVISE_CTLDIR " directory") ;
case 0 : strerr_diefu3x(100, "control ", argv[0], ": supervisor not listening") ;
}
return 0 ;
diff --git a/src/supervision/s6-svscan.c b/src/supervision/s6-svscan.c
index 7016236..3f63c2d 100644
--- a/src/supervision/s6-svscan.c
+++ b/src/supervision/s6-svscan.c
@@ -8,6 +8,7 @@
#include <fcntl.h>
#include <signal.h>
+#include <skalibs/posixplz.h>
#include <skalibs/allreadwrite.h>
#include <skalibs/sgetopt.h>
#include <skalibs/types.h>
@@ -18,7 +19,7 @@
#include <skalibs/direntry.h>
#include <skalibs/sig.h>
#include <skalibs/selfpipe.h>
-#include <skalibs/environ.h>
+#include <skalibs/exec.h>
#include <s6/config.h>
#include <s6/s6-supervise.h>
@@ -331,7 +332,7 @@ static void trystart (unsigned int i, char const *name, int islog)
&& !strcmp(name, SPECIAL_LOGGER_SERVICE)
&& fd_move(2, consoleholder) < 0) /* autoclears coe */
strerr_diefu1sys(111, "restore console fd for service " SPECIAL_LOGGER_SERVICE) ;
- xpathexec_run(S6_BINPREFIX "s6-supervise", cargv, (char const **)environ) ;
+ xexec_a(S6_BINPREFIX "s6-supervise", cargv) ;
}
}
services[i].pid[islog] = pid ;
@@ -496,16 +497,8 @@ int main (int argc, char const *const *argv)
{
case 'c' : if (uint0_scan(l.arg, &max)) break ;
case 't' : if (uint0_scan(l.arg, &t)) break ;
- case 'd' :
- if (!uint0_scan(l.arg, &notif)) dieusage() ;
- if (notif < 3) strerr_dief1x(100, "notification fd must be 3 or more") ;
- if (fcntl(notif, F_GETFD) < 0) strerr_dief1sys(100, "invalid notification fd") ;
- break ;
- case 'X' :
- if (!uint0_scan(l.arg, &consoleholder)) dieusage() ;
- if (consoleholder < 3) strerr_dief1x(100, "console holder fd must be 3 or more") ;
- if (fcntl(consoleholder, F_GETFD) < 0) strerr_dief1sys(100, "invalid console holder fd") ;
- break ;
+ case 'd' : if (!uint0_scan(l.arg, &notif)) dieusage() ; break ;
+ case 'X' : if (!uint0_scan(l.arg, &consoleholder)) dieusage() ; break ;
default : dieusage() ;
}
}
@@ -515,11 +508,10 @@ int main (int argc, char const *const *argv)
if (max < 2) max = 2 ;
}
- /* Init phase.
- If something fails here, we can die, because it means that
- something is seriously wrong with the system, and we can't
- run correctly anyway.
- */
+ if (notif < 3) strerr_dief1x(100, "notification fd must be 3 or more") ;
+ if (fcntl(notif, F_GETFD) < 0) strerr_dief1sys(100, "invalid notification fd") ;
+ if (consoleholder < 3) strerr_dief1x(100, "console holder fd must be 3 or more") ;
+ if (fcntl(consoleholder, F_GETFD) < 0) strerr_dief1sys(100, "invalid console holder fd") ;
if (argc && (chdir(argv[0]) < 0)) strerr_diefu1sys(111, "chdir") ;
if (consoleholder && coe(consoleholder) < 0) strerr_diefu1sys(111, "coe console holder") ;
@@ -560,9 +552,7 @@ int main (int argc, char const *const *argv)
services = blob ;
tain_now_set_stopwatch_g() ;
-
- /* Loop phase.
- From now on, we must not die.
+ /* From now on, we must not die.
Temporize on recoverable errors, and panic on serious ones. */
while (cont)