DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

Lock(TCL_ADM)


Lock: LockPread, LockPwrite, LockVread, LockVwrite -- apply/release read/write locks on files

Syntax

LockPread filename
LockPwrite filename
LockVread filehandle
LockVwrite filehandle

Description

These calls provide blocking, advisory read and/or write locks for data synchronization. A read lock permits additional read locks but not a write lock. A write lock prohibits any additional locks from being applied. Locking calls will block until the lock can be applied. Locks apply to the entire file.

LockPread
applies a read lock on the given file and returns a file handle for use by LockVread. If a write lock exists on the file, the call does not return until the lock has been released and the requested lock is set.

LockVread
releases the read lock corresponding to the given file handle.

LockPwrite
applies a write lock on the given file and returns a file handle for use by LockVwrite. If a read or write lock exists on the file, the call does not return until the lock has been released and the requested lock is set.

LockVwrite
releases the write lock corresponding to the given file handle.

Arguments


filename
full pathname of a filesystem object (file, directory etc.)

filehandle
lock file handle returned by LockPread orLockPwrite.

Return values

LockPread and LockPwrite return a lock file handle for use with subsequent LockVread or LockVwrite calls. Note, this is not a generic Tcl file handle that may be used with generic IO functions; it is internal to the lock subsystem.

Errors

Errors encountered (such as non-existent file, wrong permissions) will result in a throw with a SCOadmin error stack. See Error(TCL_ADM) or catch(TCL).

Notes

These functions use System V advisory locks. For each lock, the caller must have the requested permissions on the file to be locked in order for the lock to succeed (such as write permission in order to apply a write lock, and so on).

See also

fcntl(S).
16 September 2002
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003