On 10/13/2011 03:05 AM, Pádraig Brady wrote:
Note the above is easier to express in shell like:
[ -e "$file" ] || touch "$file"
But that is racy. If you were using touch for locking purposes
then adding -e (must create), would allow one to add O_EXCL to the open(),
You can avoid that race, while still accomplishing your goal of creating
the file if it does not exist, all without corrupting timestamps if it
does exist, by using straight shell:
(set -C; : > "$file") 2>/dev/null || :
--
Eric Blake ebl...@redhat.com +1-801-349-2682
Libvirt virtualization library http://libvirt.org