*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->Linux man pages -> lockf (3)              
Title
Content
Arch
Section
 

LOCKF(3)

Contents


NAME    [Toc]    [Back]

       lockf - apply, test or remove a POSIX lock on an open file

SYNOPSIS    [Toc]    [Back]

       #include <sys/file.h>

       int lockf(int fd, int cmd, off_t len);

DESCRIPTION    [Toc]    [Back]

       Apply, test or remove a POSIX lock on an open file.  The file is specified
 by fd.  This call is just an interface for fcntl(2).  Valid operations
 are given below:


	      F_LOCK	Set  an  exclusive  lock to the file. Only one process
			may hold an exclusive lock for a given file at a given
			time.  If  the	file is already locked it blocks until
			the previous lock is released.

	      F_TLOCK	Same as F_LOCK	but  never  blocks  and  return  error
			instead if the file is already locked.

	      F_ULOCK	Unlock the file.

	      F_TEST	Test the lock: return 0 if fd is unlocked or locked by
			this process; return  -1,  set	errno  to  EACCES,  if
			another process holds the lock.


RETURN VALUE    [Toc]    [Back]

       On  success,  zero is returned.	On error, -1 is returned, and errno is
       set appropriately.

ERRORS    [Toc]    [Back]

       EAGAIN The file is locked and the LOCK_NB flag was selected, or	operation
  is	prohibited  because the file has been memory-mapped by
	      another process.

       EBADF  fd is not an open file descriptor.

       EDEADLK    [Toc]    [Back]
	      Specified lock operation would cause a deadlock.

       EINVAL An invalid operation was specified in fd.

       ENOLCK Too many segment locks open, lock table is full.

CONFORMING TO    [Toc]    [Back]

       SYSV

SEE ALSO    [Toc]    [Back]

      
      
       fcntl(2), flock(2)
       There are also locks.txt and mandatory.txt in /usr/src/linux/Documenta-
       tion.



Linux 2.0			  1997-08-06			      LOCKF(3)
[ Back ]
 Similar pages
Name OS Title
flock FreeBSD apply or remove an advisory lock on an open file
flock IRIX apply or remove an advisory lock on an open file
flock Tru64 Apply or remove an advisory lock on an open file
flock OpenBSD apply or remove an advisory lock on an open file
flock Linux apply or remove an advisory lock on an open file
flock NetBSD apply or remove an advisory lock on an open file
pipcrm HP-UX remove a POSIX message queue or a POSIX named semaphore
lockf Tru64 Lock and unlocks regions of open file descriptors
sem_trywait HP-UX lock a POSIX semaphore
sem_wait HP-UX lock a POSIX semaphore
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service