atomically creating a file if it doesn't exist.

From: Harvey J. Stein <hjstein_at_MATH.HUJI.AC.IL>
Date: Mon, 15 May 1995 21:13:43 +0300

I'd like to use files for locking (if the lock file exists, the
resource is locked). This requires the ability to create a file if it
doesn't exist, and return an error if it does exist (such as with the
unix system call creat(filename, 666)). Is there a way to do this
already in STk, or do I need to add creat (or open, for that matter)
to unix.c? I can't do:

   (if (not (file-exists? lockfilename))
       (open-output-file lockfilename
      #f))

because someone else might create the lock file between the time that
file-exists? checks for its existence and the time that
open-output-file creates it.

Thanks,

Dr. Harvey J. Stein
Berger Financial Research
hjstein_at_math.huji.ac.il
Received on Mon May 15 1995 - 20:14:25 CEST

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