summaryrefslogtreecommitdiff
path: root/src/daemontools-extras
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2021-05-04 12:16:18 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2021-05-04 12:16:18 +0000
commit95157aa7d44750e248665744518f453ec65e2636 (patch)
tree658736d14430f4188c7e0420e3f3a23de0936c1a /src/daemontools-extras
parent80882cf01005ea49672c496eff9f622d5ee5751d (diff)
downloads6-95157aa7d44750e248665744518f453ec65e2636.tar.xz
Also allow shared locks in s6lockd-helper
Diffstat (limited to 'src/daemontools-extras')
-rw-r--r--src/daemontools-extras/deps-exe/s6-setlock1
-rw-r--r--src/daemontools-extras/s6-setlock.c27
2 files changed, 3 insertions, 25 deletions
diff --git a/src/daemontools-extras/deps-exe/s6-setlock b/src/daemontools-extras/deps-exe/s6-setlock
index 756dcc2..9bb3918 100644
--- a/src/daemontools-extras/deps-exe/s6-setlock
+++ b/src/daemontools-extras/deps-exe/s6-setlock
@@ -1,3 +1,4 @@
+libs6lockd.a.xyzzy
-lskarnet
${SYSCLOCK_LIB}
${SPAWN_LIB}
diff --git a/src/daemontools-extras/s6-setlock.c b/src/daemontools-extras/s6-setlock.c
index 6ba2ec8..6497600 100644
--- a/src/daemontools-extras/s6-setlock.c
+++ b/src/daemontools-extras/s6-setlock.c
@@ -14,6 +14,7 @@
#include <skalibs/exec.h>
#include <s6/config.h>
+#include "s6lockd.h"
#define USAGE "s6-setlock [ -r | -w ] [ -n | -N | -t timeout ] lockfile prog..."
#define dieusage() strerr_dieusage(100, USAGE)
@@ -40,31 +41,7 @@ int main (int argc, char const *const *argv)
argc -= subgetopt_here.ind ; argv += subgetopt_here.ind ;
if (argc < 2) dieusage() ;
- if (nb < 2)
- {
- int r, fd ;
- if (ex)
- {
- fd = open_create(argv[0]) ;
- if (fd < 0) strerr_diefu3sys(111, "open ", argv[0], " for writing") ;
- }
- else
- {
- fd = open_read(argv[0]) ;
- if (fd < 0)
- {
- if (errno != ENOENT) strerr_diefu3sys(111, "open ", argv[0], " for reading") ;
- fd = open_create(argv[0]) ;
- if (fd < 0) strerr_diefu2sys(111, "create ", argv[0]) ;
- close(fd) ;
- fd = open_read(argv[0]) ;
- if (fd < 0) strerr_diefu3sys(111, "open ", argv[0], " for reading") ;
- }
- }
- r = fd_lock(fd, ex, nb) ;
- if (!r) errno = EBUSY ;
- if (r < 1) strerr_diefu2sys(1, "lock ", argv[0]) ;
- }
+ if (nb < 2) s6lockd_openandlock(argv[0], ex, nb) ;
else
{
char const *cargv[4] = { "s6lockd-helper", ex ? "w" : "r", argv[0], 0 } ;