A C function that allows the program to request a shared or exclusive lock on a file. Returns 0 on sucess and -1 on failure.

  #define LOCK_SH 1       /* shared lock */
  #define LOCK_EX 2       /* exclusive lock */
  #define LOCK_NB 4       /* don't block when locking */
  #define LOCK_UN 8       /* unlock */
  int flock(
          int filedes,
          int operation );

(from the flock() man page)

Where filedes is a file descriptor returned by open() or fcntl() and operation is one of the constants defined in the above block.

Log in or register to write something here or to contact authors.