summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoland Hieber <r.hieber@pengutronix.de>2018-05-31 13:36:24 +0200
committerRoland Hieber <r.hieber@pengutronix.de>2018-06-04 15:44:39 +0200
commit2f200bbda9d630294bcd0d2ad3b5b8c3176b5ad4 (patch)
treefc078258915816759957725ebcea9a58d8332892
parent5ef3f9b16827478a3bfd24bc07de89a7732d93b9 (diff)
downloaddt-utils-2f200bbda9d630294bcd0d2ad3b5b8c3176b5ad4.tar.gz
dt-utils-2f200bbda9d630294bcd0d2ad3b5b8c3176b5ad4.tar.xz
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 <r.hieber@pengutronix.de>
-rw-r--r--src/barebox-state.c4
1 files 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);
}