From 5d3ae35331e3c19343b30d5916d886727ddc2d29 Mon Sep 17 00:00:00 2001 From: Christian Ruppert Date: Mon, 11 Jul 2011 17:39:31 +0200 Subject: [PATCH] Leave the lock loop in case of errors OpenRC uses locking in parallel mode and it waits until it can lock. There was no error checking before so it never left the loop in case of errors. This patch will leave the loop as soon as open() fails. X-Gentoo-Bug: 360013 X-Gentoo-Bug-URL: https://bugs.gentoo.org/360013 --- src/rc/runscript.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/src/rc/runscript.c b/src/rc/runscript.c index f62e8dc..637b1a9 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -300,9 +300,15 @@ write_prefix(const char *buffer, size_t bytes, bool *prefixed) /* Spin until we lock the prefix */ for (;;) { lock_fd = open(PREFIX_LOCK, O_WRONLY | O_CREAT, 0664); - if (lock_fd != -1) + if (lock_fd != -1) { if (flock(lock_fd, LOCK_EX) == 0) break; + } + else { + eerror("Error: open(%s) failed:: %s", PREFIX_LOCK, strerror(errno)); + eerror("Please make sure you have enough permissions"); + break; + } close(lock_fd); } -- 1.7.3.4