summaryrefslogtreecommitdiff
path: root/src/libs6rc
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2020-12-10 19:55:35 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2020-12-10 19:55:35 +0000
commit84586ab9fc1f3540f7182c822d779d85f6ffafa7 (patch)
tree9c7040e731a2f263cac7e999d6fa2aca3c88e734 /src/libs6rc
parent124f056395b279e0ef306767975cecc380635ce4 (diff)
downloads6-rc-84586ab9fc1f3540f7182c822d779d85f6ffafa7.tar.xz
You want shared locks, Sherlock
Diffstat (limited to 'src/libs6rc')
-rw-r--r--src/libs6rc/s6rc_lock.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/libs6rc/s6rc_lock.c b/src/libs6rc/s6rc_lock.c
index e879fcc..9daaa34 100644
--- a/src/libs6rc/s6rc_lock.c
+++ b/src/libs6rc/s6rc_lock.c
@@ -2,6 +2,7 @@
#include <string.h>
#include <errno.h>
+#include <fcntl.h>
#include <skalibs/djbunix.h>
@@ -18,9 +19,8 @@ int s6rc_lock (char const *live, int lwhat, int *llfd, char const *compiled, int
char lfn[llen + 6] ;
memcpy(lfn, live, llen) ;
memcpy(lfn + llen, "/lock", 6) ;
- lfd = open_create(lfn) ;
+ lfd = open(lfn, O_RDWR | O_CREAT | O_TRUNC | O_NONBLOCK | O_CLOEXEC, 0644) ;
if (lfd < 0) return 0 ;
- if (coe(lfd) < 0) goto lerr ;
r = fd_lock(lfd, lwhat > 1, !blocking) ;
if (!r) errno = EBUSY ;
if (r < 1) goto lerr ;
@@ -32,15 +32,13 @@ int s6rc_lock (char const *live, int lwhat, int *llfd, char const *compiled, int
char cfn[clen + 6] ;
memcpy(cfn, compiled, clen) ;
memcpy(cfn + clen, "/lock", 6) ;
- cfd = open_create(cfn) ;
+ cfd = open(cfn, O_RDWR | O_CREAT | O_TRUNC | O_NONBLOCK | O_CLOEXEC, 0644) ;
if (cfd < 0)
if (cwhat > 1 || errno != EROFS) goto lerr ;
else cfd = -errno ;
else
{
- int r ;
- if (coe(cfd) < 0) goto cerr ;
- r = fd_lock(cfd, cwhat > 1, !blocking) ;
+ int r = fd_lock(cfd, cwhat > 1, !blocking) ;
if (!r) errno = EBUSY ;
if (r < 1) goto cerr ;
}