1open_excl(3) Library Functions Manual open_excl(3)
2
3
4
6 open_excl - open a file for exclusive writing
7
9 #include <open.h>
10
11 int open_excl(const char *filename);
12
14 open_excl opens the file filename for writing and returns the file han‐
15 dle. The file may not exist before the call to open_excl. The file
16 will be created with mode 0600.
17
18 If there was an error creating the file, open_excl returns -1 and sets
19 errno accordingly.
20
21 Since open_excl relies on the O_EXCL flag to open, it does not work
22 reliably over NFS (the NFS protocol is broken) and must be emulated
23 using a lock file (create a file with a unique file name and link(2) it
24 to the lock file. Then stat the lock file and see if the link count is
25 2).
26
28 open(2)
29
30
31
32 open_excl(3)