bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

patch for touch.c allowing O_EXCL


From: Andreas Aardal Hanssen
Subject: patch for touch.c allowing O_EXCL
Date: Fri, 7 Sep 2001 14:03:10 +0200 (CEST)

Hi!

This patch allows the command line option '-x', which enables
create-if-exist.

On file opening, if the file already exists, touch will exit with
errorcode 1 without changing the state of the target file. If the file
doesn't exist, it is created and the return code of touch is 0. This
is an atomic operation allowing touch to do TAS (test-and-set).

This allows creation of critical regions in bash scripts.

if touch -x .lock; then
    # critical region begin

    # critical region end
    rm -f .lock
fi

Best regards,

Andreas

Attachment: fileutils-4.1-touch-mutex-patch
Description: fileutils-4.1-touch-mutex-patch


reply via email to

[Prev in Thread] Current Thread [Next in Thread]