Siebel eScript Language Reference > C Language Library Reference > Clib File and Directory Methods >

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)

Table 126 describes the arguments for the Clib Lock File method.

Table 126. 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:

  • LOCK_EX. Lock for exclusive use.
  • LOCK_SH. Lock for shared use.
  • LOCK_UN. Unlock.
  • LOCK_NB. Nonblock.
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.

Siebel eScript Language Reference Copyright © 2013, Oracle and/or its affiliates. All rights reserved. Legal Notices.