From 9cf44c27876b3236de12fa60ff9d207f02328aa1 Mon Sep 17 00:00:00 2001 From: Leah Neukirchen Date: Wed, 15 Dec 2021 21:37:16 +0100 Subject: nq: open lock files read-only when we don't write into them flock(fd, LOCK_EX) should still work. --- nq.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nq.c b/nq.c index 985c165..10ae988 100644 --- a/nq.c +++ b/nq.c @@ -313,9 +313,9 @@ wait: int fd; if (strchr(argv[i], '/')) - fd = open(argv[i], O_RDWR); + fd = open(argv[i], O_RDONLY); else - fd = openat(dirfd, argv[i], O_RDWR); + fd = openat(dirfd, argv[i], O_RDONLY); if (fd < 0) continue; @@ -347,7 +347,7 @@ again: strlen(ent->d_name) < sizeof(newestlocked))) continue; - int fd = openat(dirfd, ent->d_name, O_RDWR); + int fd = openat(dirfd, ent->d_name, O_RDONLY); if (fd < 0) continue; @@ -365,7 +365,7 @@ again: } if (*newestlocked) { - int fd = openat(dirfd, newestlocked, O_RDWR); + int fd = openat(dirfd, newestlocked, O_RDONLY); if (fd >= 0) { flock(fd, LOCK_SH); /* sit it out. */ close(fd); -- cgit 1.4.1