On Sat, Dec 12, 2009 at 5:57 AM, Pedro <[email protected]> wrote:
> --- I wrote:
>>
>> How to lock a file on Posix systems?
>>
>> I know how joe and OpenOffice lock the file being edited. But:
>>
>> What is the right way to lock a file across multiple processes?
>>
>> The method that joe and OpenOffice use to lock the file is not protected 
>> against different applications.
>
>  What I want to know is:
>
>  How to mandatory lock a file on Posix systems?

The two are incompatible it would appear (though my grasp on POSIX
isn't as strong as it is for Standard C - if you have evidence to the
contrary I'd be pleased to be corrected.)

I suggest you find mandatory-locking.txt (or mandatory.txt under 2.4
it would appear) on any Linux system and grep it for posix. For
example the following appear in it:

# Note 2: POSIX.1 does not specify any scheme for mandatory locking, despite
# borrowing the fcntl() locking scheme from System V. The mandatory locking
# scheme is defined by the System V Interface Definition (SVID) Version 3.
----
# 1. Mandatory locks can only be applied via the fcntl()/lockf() locking
#  interface - in other words the System V/POSIX interface. BSD style
# locks using flock() never result in a mandatory lock.

(Taken from 2.6.32, though it doesn't appear to have changed (in
content) any from 2.4.)

If you don't have a linux system to hand,
<http://www.mjmwired.net/kernel/Documentation/filesystems/mandatory-locking.txt>
should suffice.

-- 
PJH

http://shabbleland.myminicity.com/
http://www.chavgangs.com/register.php?referer=9375
http://www.kongregate.com/?referrer=Shabble

Reply via email to