From 970893adf3a2f0f7330c4839a716566de14171a3 Mon Sep 17 00:00:00 2001 From: Alexander Mezin Date: Sat, 2 Feb 2013 15:15:19 -0600 Subject: [PATCH] runscript: retry prefix flock if it is interrupted by a signal Reported-by: Pacho Ramos X-Gentoo-Bug: 434800 X-Gentoo-Bug-URL: https://bugs.gentoo.org/show_bug.cgi?id=434800 --- src/rc/runscript.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/rc/runscript.c b/src/rc/runscript.c index e504e4a9..0eea335f 100644 --- a/src/rc/runscript.c +++ b/src/rc/runscript.c @@ -311,8 +311,12 @@ write_prefix(const char *buffer, size_t bytes, bool *prefixed) lock_fd = open(PREFIX_LOCK, O_WRONLY | O_CREAT, 0664); if (lock_fd != -1) { - if (flock(lock_fd, LOCK_EX) != 0) - eerror("flock() failed: %s", strerror(errno)); + while (flock(lock_fd, LOCK_EX) != 0) { + if (errno != EINTR) { + eerror("flock() failed: %s", strerror(errno)); + break; + } + } } #ifdef RC_DEBUG else