Re: Atomic Create

From: Scanner <eluce_at_lehman.com>
Date: Mon, 15 May 1995 17:01:04 -0400

> The UNIX system call
> link(name1,name2)
> returns EEXIST if name2 exists.
>
> You can use this for atomic creates by creating
> the temp file, then renaming it with link to the desired
> name. If you're the second guy to create it, you get EEXIST.

You can also do an open(2), with O_EXCL|O_CREAT. As the man page
(on SunOS) says:

     O_EXCL If O_EXCL and O_CREAT are set, open() will
                    fail if the file exists. This can be used to
                    implement a simple exclusive access locking
                    mechanism.

--Scanner (scanner_at_apricot.com)
Received on Mon May 15 1995 - 23:04:53 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST