[Cuis-dev] Do we have an equivalent of Unix 'flock' ?

Nicola Mingotti nmingotti at gmail.com
Fri Sep 24 00:31:57 PDT 2021


Hi Dave,

extra information is extremely welcomed ! Thank you !

The day I absolutely needed it i solved with a temporary hack,
I sent from Cuis this command, to read a file:
flock fooFile.txt -c 'cat fooFile.txt'

I will hit the necessity of using a lock again, next time I am going to 
implement it well.

When I will do I will also document a minimum procedure for future users 
in the
"CuisCook", there at the moment there is only a reference to the info 
you sent me.
That is already a very good starting point !

Thank you again

bye
Nicola






On 9/24/21 2:12 AM, David T. Lewis via Cuis-dev wrote:
> Nicola,
>
> Here is a bit more information for background.
>
> 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.
>
> HTH,
> Dave
>
>
> On Wed, Sep 22, 2021 at 10:19:57AM +0200, Nicola Mingotti via Cuis-dev wrote:
>> thank you Dave, I will study it.
>>
>> bye
>> Nicola
>>
>>
>>
>>
>> On 9/21/21 10:08 PM, David T. Lewis wrote:
>>> On Tue, Sep 21, 2021 at 10:57:16AM +0200, Nicola Mingotti via Cuis-dev
>>> wrote:
>>>> Hi again,
>>>>
>>>> I have another question, as far as you know is it already implemented
>>>> somewhere and equivalent of Unix 'flock' ?
>>>>
>>>> bye
>>>> Nicola
>>>>
>>>>
>>> Hi Nicola,
>>>
>>> Try loading OSProcess (Feature require: 'OSProcess').
>>>
>>> Then look at UnixProcessFileLockTestCase for examples of how the file
>>> locking works on Unix/Linux and OS X.
>>>
>>> Dave
>>>
>> -- 
>> Cuis-dev mailing list
>> Cuis-dev at lists.cuis.st
>> https://lists.cuis.st/mailman/listinfo/cuis-dev
>>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210924/45098a13/attachment.htm>


More information about the Cuis-dev mailing list