In message <s8d7897b.039 / email1.cuna.com>
DDouthitt / cuna.com writes:

> This is not guaranteed to work.  This shows the danger of locks: in the
> time between the test (File.exist?) and the creation (File.open) someone
> else could interfere, and a lock could already be there when File.open
> is reached.

....And same is true when system is used.  Why can you believe a file
existence check and a creation in the shell are atomic?

File locking are usually implemented with atomic operations such as
symlink or mkdir.  These operations are atomic --- an existence check
and a creation of a named symbolic link/directory can not be interrupted
by any process.

# I can not explain any implementation of these are atomic, but
# usually we can believe they are.


In unix-like systems, symlink is preferred since it can make a
symbolic link to any file --- even non existent or it can not exist in
a file system.  However if extreme portability is necessary, only
mkdir can be candidate of lock operation.


-- 
kjana / os.xaxon.ne.jp                                 March 22, 2000
What is done can't be undone.