Subject: Re: touch(1) enchancement, mkstemp(1)
To: None <current-users@NetBSD.ORG>
From: Alan Barrett <email@example.com>
Date: 02/11/1998 09:55:35
On Wed, 11 Feb 1998, Darren Reed wrote:
> if [ ! -e foo ] ; then
> touch foo
> - race condition between test and touch running.
Does this work?
touch foo.new.$$ # XXX: we hope that this is a unique name
ln foo.new.$$ foo # atomic operation, fails if foo exists
rm -f foo.new.$$ # delete temp file unconditionally
--apb (Alan Barrett)