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.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/daemontools-extras/s6-log.c b/src/daemontools-extras/s6-log.c
index 2f8438d..5128751 100644
--- a/src/daemontools-extras/s6-log.c
+++ b/src/daemontools-extras/s6-log.c
@@ -580,13 +580,14 @@ static inline void logdir_init (unsigned int index, uint32_t s, uint32_t n, uint
ldp->fd = -1 ;
ldp->rstate = ROTSTATE_WRITABLE ;
r = mkdir(ldp->dir, S_IRWXU | S_ISGID) ;
- if ((r < 0) && (errno != EEXIST)) strerr_diefu2sys(111, "mkdir ", name) ;
+ if (r < 0 && errno != EEXIST) strerr_diefu2sys(111, "mkdir ", name) ;
memcpy(x, name, dirlen) ;
memcpy(x + dirlen, "/lock", 6) ;
- ldp->fdlock = open_append(x) ;
- if ((ldp->fdlock) < 0) strerr_diefu2sys(111, "open_append ", x) ;
- if (lock_exnb(ldp->fdlock) < 0) strerr_diefu2sys(111, "lock_exnb ", x) ;
- if (coe(ldp->fdlock) < 0) strerr_diefu2sys(111, "coe ", x) ;
+ ldp->fdlock = openc_create(x) ;
+ if (ldp->fdlock < 0) strerr_diefu2sys(111, "open ", x) ;
+ r = fd_lock(ldp->fdlock, 1, 1) ;
+ if (!r) errno = EBUSY ;
+ if (r < 1) strerr_diefu2sys(111, "lock ", x) ;
memcpy(x + dirlen + 1, "current", 8) ;
if (stat(x, &st) < 0)
{