Using file locks
Jump to navigation
Jump to search
TODO.
- This page has to be still made. Here follows info to do it provided by Dave (see mailing 23-24-Sep-2021)
- See class:
UnixProcessFileLockTestCase
- See class:
OSFileLock
File locking is done with posix advisory file locking, as describe in the man(2) flock man page https://man7.org/linux/man-pages/man2/fcntl.2.html The necessary primitives are in all of the unix VMs, and are implemented in the UnixOSProcessPlugin. The plugin source is maintained at http://www.squeaksource.com/OSProcessPlugin. I am attaching a copy of the three primitive methods so you can see what they are doing. These are Smalltalk methods in the plugin that are translated to C code. You can find the generated C code for these methods somewhere in the plugin code at http://squeakvm.org/cgi-bin/viewvc.cgi/squeak/trunk/src/plugins/UnixOSProcessPlugin/UnixOSProcessPlugin.c?revision=3807&view=markup The methods in package OSProcess make use of these primitives to implement file locking in Squeak/Cuis, and the unit tests that I referenced show how it works in the image. UnixOSProcessAccessor provides the direct interface to the primitives (see category 'file locking'), and OSFileLock and OSFileRegionLock represent locks on files or regions within a file.