Opening files in an exclusive mode

Einar Karttunen ekarttun@REDACTED
Tue May 11 11:20:04 CEST 2004


Hello

I want to open files for writing in an exclusive mode i.e. 
fail if they already exist. In C the equivalent is
open(name, O_CREAT|O_EXCL|O_WRONLY). The file module
does not seem to allow for this.

Of course I could first try opening for reading and then
open for write if the first open failed. This creates a hole 
for races though. 

An another approach would be to have one erlang process creating 
the files and so avoid the races. This would not protect from external 
races though... What would be the best solution?

- Einar Karttunen



More information about the erlang-questions mailing list