commit 69075d8b479fd85bfea95a914ae3fa89c27fa586
parent 1958bb68e9a812366a7c6d01bcda54486e477cfb
Author: Laurent Bercot <ska-skaware@skarnet.org>
Date: Mon, 16 Nov 2020 03:45:49 +0000
Fix supervise/svscan startup when the control dir already exists
Diffstat:
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git 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) ;