On 2010-09-23, loial <jldunn2...@gmail.com> wrote:
> How can I check whether a file is being written to by another process
> before I access it?

You mean "written to" or "open for possible writing"?

It may be possible (with sufficient privileges) to determine that a
file has been opened for writing.  I don't think you can detect
being-written-to.

More importantly, though, the question is irrelevant, because even if
you absolutely, conclusively, prove that a file is not open nor being
written to, before your next machine instruction loads, the file could
be opened and rewritten multiple times by whole new processes that weren't
even running when you checked.

I suggest you look into advisory locks.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nos...@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!
I am not speaking for my employer, although they do rent some of my opinions.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to