Programming Interfaces Guide

Opening a File for Locking

You can only request a lock for a file with a valid open descriptor. For read locks, the file must be open with at least read access. For write locks, the file must also be open with write access. In the following example, a file is opened for both read and write access.

 	filename = argv[1];
 	fd = open (filename, O_RDWR);
 	if (fd < 0) {