diff options
| author | Christian Ullrich <chris@chrullrich.net> | 2026-05-03 15:35:10 +0000 |
|---|---|---|
| committer | Dag-Erling Smørgrav <des@FreeBSD.org> | 2026-05-03 15:35:10 +0000 |
| commit | d90513ea85693da0ca5955173609f4e81e38ae16 (patch) | |
| tree | 1aeecfbbf46cfbfeb43e2595c86def1121c7e2c8 | |
| parent | 0095c1425633cb6a40fd86fc870ac5945363df2f (diff) | |
| -rw-r--r-- | usr.bin/lockf/lockf.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/usr.bin/lockf/lockf.c b/usr.bin/lockf/lockf.c index 16bae36a21e0..076d28b7ddd5 100644 --- a/usr.bin/lockf/lockf.c +++ b/usr.bin/lockf/lockf.c @@ -320,10 +320,14 @@ acquire_lock(union lock_subject *subj, int flags, int silent) int fd; if (fdlock) { + int lflags = LOCK_EX; + assert(subj->subj_fd >= 0 && subj->subj_fd <= INT_MAX); fd = (int)subj->subj_fd; - if (flock(fd, LOCK_EX | LOCK_NB) == -1) { + if ((flags & O_NONBLOCK) == O_NONBLOCK) + lflags |= LOCK_NB; + if (flock(fd, lflags) == -1) { if (errno == EAGAIN || errno == EINTR) return (-1); err(EX_CANTCREAT, "cannot lock fd %d", fd); |
