summaryrefslogtreecommitdiff
path: root/src/daemontools-extras/s6-log.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/daemontools-extras/s6-log.c')
-rw-r--r--src/daemontools-extras/s6-log.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c
index bbb92b1..c3aec9c 100644
--- a/src/daemontools-extras/s6-log.c
+++ b/src/daemontools-extras/s6-log.c
@@ -306,27 +306,21 @@ static int finish (logdir_t *ldp, char const *name, char suffix)
static inline void exec_processor (logdir_t *ldp)
{
char const *cargv[4] = { EXECLINE_EXTBINPREFIX "execlineb", "-Pc", ldp->processor, 0 } ;
- unsigned int dirlen = str_len(ldp->dir) ;
int fd ;
- char x[dirlen + 10] ;
PROG = "s6-log (processor child)" ;
- byte_copy(x, dirlen, ldp->dir) ;
- byte_copy(x + dirlen, 10, "/previous") ;
- fd = open_readb(x) ;
- if (fd < 0) strerr_diefu2sys(111, "open_readb ", x) ;
- if (fd_move(0, fd) < 0) strerr_diefu2sys(111, "fd_move ", x) ;
- byte_copy(x + dirlen + 1, 10, "processed") ;
- fd = open_trunc(x) ;
- if (fd < 0) strerr_diefu2sys(111, "open_trunc ", x) ;
- if (fd_move(1, fd) < 0) strerr_diefu2sys(111, "fd_move ", x) ;
- byte_copy(x + dirlen + 1, 6, "state") ;
- fd = open_readb(x) ;
- if (fd < 0) strerr_diefu2sys(111, "open_readb ", x) ;
- if (fd_move(4, fd) < 0) strerr_diefu2sys(111, "fd_move ", x) ;
- byte_copy(x + dirlen + 1, 9, "newstate") ;
- fd = open_trunc(x) ;
- if (fd < 0) strerr_diefu2sys(111, "open_trunc ", x) ;
- if (fd_move(5, fd) < 0) strerr_diefu2sys(111, "fd_move ", x) ;
+ if (chdir(ldp->dir) < 0) strerr_diefu2sys(111, "chdir to ", ldp->dir) ;
+ fd = open_readb("previous") ;
+ if (fd < 0) strerr_diefu3sys(111, "open_readb ", ldp->dir, "/previous") ;
+ if (fd_move(0, fd) < 0) strerr_diefu3sys(111, "fd_move ", ldp->dir, "/previous") ;
+ fd = open_trunc("processed") ;
+ if (fd < 0) strerr_diefu3sys(111, "open_trunc ", ldp->dir, "/processed") ;
+ if (fd_move(1, fd) < 0) strerr_diefu3sys(111, "fd_move ", ldp->dir, "/processed") ;
+ fd = open_readb("state") ;
+ if (fd < 0) strerr_diefu3sys(111, "open_readb ", ldp->dir, "/state") ;
+ if (fd_move(4, fd) < 0) strerr_diefu3sys(111, "fd_move ", ldp->dir, "/state") ;
+ fd = open_trunc("newstate") ;
+ if (fd < 0) strerr_diefu3sys(111, "open_trunc ", ldp->dir, "/newstate") ;
+ if (fd_move(5, fd) < 0) strerr_diefu3sys(111, "fd_move ", ldp->dir, "/newstate") ;
selfpipe_finish() ;
sig_restore(SIGPIPE) ;
pathexec_run(cargv[0], cargv, (char const *const *)environ) ;