简体   繁体   中英

fcntl bytes file locking in linux

I have lock on particular bytes in file using fcntl with some values of fl.1_start and f1.1_len. while program is running, i tried to write into that file from other program on those bytes. when both programs running simultaneously, second program is writing into those locked bytes despite lock present from first program. can anyone explain why it is behaving like that?

fcntl is kind of voluntary implementation in Unix like systems. Both processes have to use it in order to work correctly.

Operations like read() and write() simply ignore locks. The other process is blocked only when explicitly calling fcntl() on the area which is already locked by other process

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM