file:open with O_EXCL mode

Dmitry Belayev <>
Wed Jan 20 12:50:08 CET 2010


I have a problem creating unique files on linux in Erlang.

In current version I cannot be sure that file I am creating is really 
unique because even if I check it's existense with filelib:is_regular 
and call file:open(..., [write,...]) some other process (not only from 
withing Erlang) can create file with the same name. What I need is 
atomically create file if it does not exist or get error if it exists.

I found old mail with workaround:
http://www.erlang.org/pipermail/erlang-questions/2009-February/041654.html
This solution works fine but I'd like not to spawn external commands.

So, is there any way to open file with O_EXCL mode from Erlang? Or will 
it be possible in next releases?


More information about the erlang-questions mailing list