From 2f200bbda9d630294bcd0d2ad3b5b8c3176b5ad4 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Thu, 31 May 2018 13:36:24 +0200 Subject: barebox-state: block while waiting for file lock In multi-processes environment, it can happen that barebox-state is called concurrently. Since barebox-state usually only runs for at most a few seconds, it is probably okay for the second process to block while wait for the file lock, so the calling entity (user or script) doesn't have to do error handling itself. Signed-off-by: Roland Hieber --- src/barebox-state.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/barebox-state.c b/src/barebox-state.c index e68b8cb..ff318b2 100644 --- a/src/barebox-state.c +++ b/src/barebox-state.c @@ -522,9 +522,9 @@ int main(int argc, char *argv[]) exit(1); } - ret = flock(lock_fd, LOCK_EX | LOCK_NB); + ret = flock(lock_fd, LOCK_EX); if (ret < 0) { - pr_err("Failed to lock. Already locked by other process /var/lock/barebox-state.\n"); + pr_err("Failed to lock /var/lock/barebox-state: %m\n"); close(lock_fd); exit(1); } -- cgit v1.2.3