diff options
author | Dominique Martinet <dominique.martinet@atmark-techno.com> | 2023-02-02 11:19:00 +0900 |
---|---|---|
committer | William Hubbs <w.d.hubbs@gmail.com> | 2023-04-24 22:06:41 -0500 |
commit | 0b9c3c080388476519ac3385c21518cc5a94735a (patch) | |
tree | d42f9943159e9dea6c9f6b369b888224a377167f /src/shared/misc.c | |
parent | a3c721b6821f1ecbe7ac567becc13df08b416f36 (diff) |
openrc-run: silence lock failures with --no-deps
work around scary warnings described in previous commit
Diffstat (limited to 'src/shared/misc.c')
-rw-r--r-- | src/shared/misc.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/shared/misc.c b/src/shared/misc.c index 28f95b34..c987ce8c 100644 --- a/src/shared/misc.c +++ b/src/shared/misc.c @@ -234,7 +234,7 @@ signal_setup_restart(int sig, void (*handler)(int)) } int -svc_lock(const char *applet) +svc_lock(const char *applet, bool ignore_lock_failure) { char *file = NULL; int fd; @@ -245,6 +245,14 @@ svc_lock(const char *applet) if (fd == -1) return -1; if (flock(fd, LOCK_EX | LOCK_NB) == -1) { + if (ignore_lock_failure) { + /* Two services with a need b, and b's start() + * calling restart --no-deps on a would cause + * harmless errors: just ignore them. + * See https://github.com/OpenRC/openrc/issues/224 + */ + exit(EXIT_SUCCESS); + } eerror("Call to flock failed: %s", strerror(errno)); close(fd); return -1; @@ -274,7 +282,7 @@ exec_service(const char *service, const char *arg) sigset_t old; struct sigaction sa; - fd = svc_lock(basename_c(service)); + fd = svc_lock(basename_c(service), false); if (fd == -1) return -1; |