From: demer@hc17031.hcsd.ca (David Emery)
Subject: Re: File/Record locking in Ada
Date: 1997/03/03
Date: 1997-03-03T00:00:00+00:00 [thread overview]
Message-ID: <c4ohd0ncig.fsf@hc17031.hcsd.ca> (raw)
In-Reply-To: 01bc259a$a035e850$fc00af88@godiva
Just remember that in POSIX, file locks are advisory. This means that
if one process locks the file using Posix_File_Locking, and another
process does -not- use Posix_File_Locking (or the C fcntl() equivalent), the
second (ill-behaved) process will get access to the file.
There's no way that I know of to get "guaranteed locking" of files against
processes that do not use POSIX_File_Locking or some other protocol
(see below).
THe other "traditional" approach to file locking is to take advantage of
the fact that the link() operation is atomic, and create a lockfile for
the file named "foo" by calling
POSIX_Files.Link
(Old_Pathname => "foo", New_Pathname => "foo.LOCK");
This will fail if New_Pathname exists (POSIX_Error, error code File_Exists), or
will atomically create the new link.
Note that POSIX doesn't know anything about NFS, so the behavior of file
locking or hard links on an NFS-mounted file system is not defined by POSIX.
dave
--
Note: if email to me bounces, use 'emery@grebyn.com'
next prev parent reply other threads:[~1997-03-03 0:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-02-25 0:00 File/Record locking in Ada Stephen Godwin
1997-02-28 0:00 ` Keith Allan Shillington
1997-03-01 0:00 ` Keith Thompson
1997-03-03 0:00 ` David Emery [this message]
1997-03-03 0:00 ` Larry Kilgallen
1997-03-05 0:00 ` David Emery
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox