diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2020-11-16 03:45:49 +0000 |
---|---|---|
committer | Laurent Bercot <ska-skaware@skarnet.org> | 2020-11-16 03:45:49 +0000 |
commit | 69075d8b479fd85bfea95a914ae3fa89c27fa586 (patch) | |
tree | 6e52f2c5ea5fc9b54ba81517ba33f1a4dc6552db | |
parent | 1958bb68e9a812366a7c6d01bcda54486e477cfb (diff) | |
download | s6-69075d8b479fd85bfea95a914ae3fa89c27fa586.tar.xz |
Fix supervise/svscan startup when the control dir already exists
-rw-r--r-- | src/libs6/s6_supervise_lock_mode.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/libs6/s6_supervise_lock_mode.c b/src/libs6/s6_supervise_lock_mode.c index b6b0829..d807bec 100644 --- a/src/libs6/s6_supervise_lock_mode.c +++ b/src/libs6/s6_supervise_lock_mode.c @@ -29,21 +29,25 @@ int s6_supervise_lock_mode (char const *subdir, unsigned int subdirmode, unsigne memcpy(lock + subdirlen, "/lock", 6) ; if (mkdir(subdir, (mode_t)subdirmode) == -1) { - if (errno != EEXIST) strerr_diefu2sys(111, "mkdir ", subdir) ; - else + char buf[S6_PATH_MAX] ; + ssize_t r ; + if (errno == EEXIST) strerr_diefu2sys(111, "mkdir ", subdir) ; + r = readlink(subdir, buf, S6_PATH_MAX) ; + if (r < 0) { - char buf[S6_PATH_MAX] ; - ssize_t r = readlink(subdir, buf, S6_PATH_MAX) ; - if (r < 0) + if (errno != EINVAL) { errno = EEXIST ; strerr_diefu2sys(111, "mkdir ", subdir) ; } - if (r == S6_PATH_MAX) - { - errno = ENAMETOOLONG ; - strerr_diefu2sys(111, "readlink ", subdir) ; - } + } + else if (r == S6_PATH_MAX) + { + errno = ENAMETOOLONG ; + strerr_diefu2sys(111, "readlink ", subdir) ; + } + else + { buf[r] = 0 ; if (mkdir(buf, (mode_t)subdirmode) == -1) strerr_diefu2sys(111, "mkdir ", buf) ; |