From: Brian Candler Date: 2010-03-10T22:54:51+09:00 Subject: Re: how to test if a file is open ? Une B辿vue wrote: > then, i think, may be i'm wrong, that any text editor open a file show > it and close it afterwards even the file is still visible in that text > editor where the Finder lock the file when it is selected. That sounds quite likely. > then lsof nor fuser are no help in my case because i want to avoid > opening a file under editing... Then the solution depends on your editor. For example, under Linux, if I create file foo then do "vi foo", lsof and fuser show that foo is not open. However, a lockfile ".foo.swp" is created, and this is what prevents another vi instance from editing it. If I edit the file in joe, then nothing is changed until I start typing into that window. Then it creates ".#foo" which is a symlink to the user and the pid of the joe instance. That is: the lock is only created when I start to modify the buffer. So there doesn't appear to be a universal way of handling this, although perhaps Apple prescribe a standard way for applications to adhere to. Useful command to see if any new dot-files are created: ls -lArt | grep ^\\. (newest files appear at the end of the list) HTH, Brian. -- Posted via http://www.ruby-forum.com/.