• massive confusion on file locks

    From candycane@VERT/CONCHAOS to All on Thu Aug 10 12:01:46 2023
    Hi!ãDoes anyone have any good recourses to learning how to make file locks in c? I've been trying to research it but there's not many recourses out there weirdly. I'm also very confused on the difference between flock(2) and fcntl locks.ããcandycaneãã===ãuser is generated from /dev/urandomãã...By annihilating desires you annihilate the mind.ã---ã þ Synchronet þ -=[ ConstructiveChaos BBS | conchaos.synchro.net ]=-ã
  • From Digital Man@VERT to candycane on Thu Aug 10 09:30:16 2023
    Re: massive confusion on file locksã By: candycane to All on Thu Aug 10 2023 12:01 pmãã > Hi!ã > Does anyone have any good recourses to learning how to make file locks in c?ããFile locks aren't really a "c" thing, but there is a POSIX standard and then there's the detailed differences in implementation on *BSD versus Linux versus Windows. For an example cross-platform abstraction/wrapper of different file and recording locking methods in C, see https://gitlab.synchro.net/main/sbbs/-/blob/master/src/xpdev/filewrap.cãã > I've been trying to research it but there's not many recourses out thereã > weirdly. I'm also very confused on the difference between flock(2) and fcntlã > locks.ããIf you want to lock an *entire* file, use flock(). If you want to lock just a *region* of a file, use fcntl().ã-- ã digital man (rob)ããSynchronet "Real Fact" #43:ãSynchronet added Baja/PCMS support with v2.00a (1994)ãNorco, CA WX: 66.8øF, 94.0% humidity, 5 mph SE wind, 0.00 inches rain/24hrsã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From candycane@VERT/CONCHAOS to Digital Man on Thu Aug 10 14:36:35 2023
    Re: massive confusion on file locksã By: Digital Man to candycane on Thu Aug 10 2023 09:30 amãã DM> If you want to lock an *entire* file, use flock(). If you want to lockã DM> just a *region* of a file, use fcntl().ããSo, whats the difference between LOCK_EX and SH? and does trying to obtain a lock already held suspend the program?ããcandycaneãã===ãuser is generated from /dev/urandomãã...Fifty-eight per cent of all cars coming into Britain are imported.ã---ã þ Synchronet þ -=[ ConstructiveChaos BBS | conchaos.synchro.net ]=-ã
  • From Digital Man@VERT to candycane on Thu Aug 10 13:23:37 2023
    Re: massive confusion on file locksã By: candycane to Digital Man on Thu Aug 10 2023 02:36 pmãã > Re: massive confusion on file locksã > By: Digital Man to candycane on Thu Aug 10 2023 09:30 amã >ã > DM> If you want to lock an *entire* file, use flock(). If you want to lockã > DM> just a *region* of a file, use fcntl().ã >ã > So, whats the difference between LOCK_EX and SH? and does trying to obtain aã > lock already held suspend the program?ããYes, that is what is meant by this line from the man page for flock():ã A call to flock() may block if an incompatible lock is held by another process. To make a nonblocking request, includeã LOCK_NB (by ORing) with any of the above operations.ããSo by default, yes, it'll suspend the program if the file is already locked with an incompatible lock from what is being attempted.ããFor more details, see "man 2 flock" or https://linux.die.net/man/2/flockã-- ã digital man (rob)ããSling Blade quote #5:ãKarl Childers (to father): You ought not killed my little brother...ãNorco, CA WX: 76.2øF, 66.0% humidity, 0 mph SSW wind, 0.00 inches rain/24hrsã---ã þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.netã
  • From candycane@VERT/CONCHAOS to Digital Man on Fri Aug 11 00:03:56 2023
    Re: massive confusion on file locksã By: Digital Man to candycane on Thu Aug 10 2023 01:23 pmãã DM> Yes, that is what is meant by this line from the man page for flock():ã DM> A call to flock() may block if an incompatible lock is held by anotherã DM> process. To make a nonblocking request, includeã DM> LOCK_NB (by ORing) with any of the above operations.ããAlright, sorry ^^". I've never worked with file locks before.ããcandycaneãã===ãuser is generated from /dev/urandomãã...Success is a public affair. Failure is a private funeral.ã---ã þ Synchronet þ -=[ ConstructiveChaos BBS | conchaos.synchro.net ]=-ã