What happens if I'm trying to set a, say, F_RDLCK lease on a file that is already open for a writing somewhere else.
fcntl(2) says
A read lease can be placed only on a file descriptor that is opened read-only.
Does it mean it should be open read-only system-wise and otherwise fcntl(2) call will fail with, presumingly EACCES? If so, is there any other way to wait for the lease to be possible other than using inotify(7) (IN_CLOSE_WRITE)?
This call:
will fail with
EAGAIN
("Resource temporarily unavailable") if underlying file is currently opened for writing in any process.It corresponds to description in manual page:
If caller itself opened
fd
for writing (i.e. not withO_RDONLY
flag), it's just a special case of this rule andfcntl()
also returnsEAGAIN
.