Clib Lock File Method
The Clib Lock File method locks or unlocks a file for simultaneous use by multiple processes. It returns one of the following values:
If successful, then it returns the following value:
0
If not successful, then it returns a nonzero integer.
Format
Clib.flock(filePointer, mode)
The following table describes the arguments for the Clib Lock File method.
Argument | Description |
---|---|
filePointer |
The file that this method locks or unlocks. The Clib Open File method or the Clib Create Temporary File method can return this file name. |
mode |
You can specify one of the following values:
|
Usage
The Clib Lock File method applies or removes an advisory lock on the file that the filePointer argument identifies. An advisory lock is a type of lock that allows cooperating processes to perform consistent operations on a file. Other processes might still reference the files, so inconsistencies might occur.
Locking allows the following types of locks:
Shared lock. Multiple processes can use shared locks on the same file at the same time. Read permission is required to obtain a shared lock.
Exclusive lock. The following configurations cannot exist on one file at the same time:
Multiple exclusive locks
Shared locks and an exclusive lock
Write permission is required to obtain an exclusive lock.
If you use the Clib Lock File method to:
Lock a file that a calling process already locked, then it removes the old lock type and replaces it with the new lock type. The Lock method locks individual files and not segments.
Lock a file that is already locked and:
You do not specify LOCK_NB in the mode argument, then it pauses the lock request until the file is free.
Specify LOCK_NB in the mode argument, then the call fails and this method returns an EWOULDBLOCK error.
Siebel eScript does not support the Clib Lock File method in a Unicode environment. It always returns 0 in a Unicode environment.