Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

55. File Locking > File Locking with flock()

File Locking with flock()

Although fcntl() provides a superset of the functionality provided by flock(), we nevertheless describe flock() because it is still used in some applications, and because it differs from fcntl() in some of the semantics of inheritance and release of locks.

#include <sys/file.h>

int flock(int fd, int operation);

Note

Returns 0 on success, or -1 on error

The flock() system call places a single lock on an entire file. The file to be locked is specified via an open file descriptor passed in fd. The operation argument specifies one of the values LOCK_SH, LOCK_EX, or LOCK_UN, which are described in Table 55-1.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint