Re: [Rd] File lock mechanisms in R

From: Prof Brian Ripley <>
Date: Tue, 03 Jul 2007 09:29:03 +0100 (BST)

On Mon, 2 Jul 2007, Henrik Bengtsson wrote:

> Hi,
> is there a (cross-platform) file-locking mechanism available in R (or
> via some package)?

I don't believe there really is a cross-platform file-locking mechanism available to any language. File-locking is an OS feature, and the semantics differ. For those unfamiliar with this, the Wikipedia article is a good start (but ignores the POSIX lockf interface).

> I am looking for a way to have one R session lock a file for
> read/write access, while being updated/modified by another R session.
> This will provide me with a-poor-mans parallelization method. It is
> ok to have so called advisory looking (as in Unix), which are
> non-mandatory to follow. If not available, I'll use lock files, but
> there are some potential problems in creating such in an atomic way.

Depends what you mean by 'atomic'. In R, the only way to have non-interruptible operations is via .Call or similar: the evaluator is interruptible at all times so it seems that this issue applies equally to all file locking from R.

> Ideally I wish to have this working on all platforms.
> Cheers
> Henrik
> ______________________________________________
> mailing list

Brian D. Ripley,        
Professor of Applied Statistics,
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

______________________________________________ mailing list
Received on Tue 03 Jul 2007 - 08:30:38 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 03 Jul 2007 - 11:35:51 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.