[Glass] Is there a Smalltalk way to lock a file?

Martin McClure martin.mcclure at gemtalksystems.com
Thu Mar 13 18:58:01 PDT 2014


On 03/13/2014 05:24 PM, James Foster wrote:
> On Mar 13, 2014, at 9:14 AM, Mariano Martinez Peck
> <marianopeck at gmail.com <mailto:marianopeck at gmail.com>> wrote:
> 
>> Hi guys,
>>
>> Do we have a method to lock a file at the OS level? I searched in
>> image but I cannot find anything. If it would work in gemstone too
>> that would be nice.
>>
>> Thanks!
>>
>> -- 
>> Mariano
>> http://marianopeck.wordpress.com
> 
> I was thinking that opening a file for write would be sufficient, but
> that isn’t what I found (on GS/S 64-bit 3.1.0.5 on Linux):

The common type of file locking in Linux is advisory, and therefore not
enforced. Locks must be explicitly obtained and checked.

See
http://en.wikipedia.org/wiki/File_locking#In_Unix-like_systems
for more information.

In GemStone/S, a #performOnServer: of flock is probably the way to go,
using the fileDescriptor of the GsFile as an argument.

Regards,

-Martin




More information about the Glass mailing list