How to check if a file is being edited? (Ruby)
I am writing some code to write out an email to a file, let you edit it in your own editor, and when you're done you can tell my code to carry on. I'd like to have it catch the common error where you still have the file open, and therefore might not have saved it. 

My first attempt was to try to obtain an exclusive lock on the file (using [File.flock](http://www.ruby-doc.org/core/classes/File.html#M000032)) but that never caught it. A bit more googling suggests that [this is a hard problem](http://www.ruby-forum.com/topic/205774).

The best suggestion appears to be to look for common lock files, eg `vi foo` will make `.foo.swp` while `joe foo` will make `.#foo`.

So the question is, is there a better way to tell if a file is being edited? And if not, is there a list of all common lock file naming conventions?
How to check if a file is being edited? (Ruby)
===

I am writing some code to write out an email to a file, let you edit it in your own editor, and when you're done you can tell my code to carry on. I'd like to have it catch the common error where you still have the file open, and therefore might not have saved it. 

My first attempt was to try to obtain an exclusive lock on the file (using [File.flock](http://www.ruby-doc.org/core/classes/File.html#M000032)) but that never caught it. A bit more googling suggests that [this is a hard problem](http://www.ruby-forum.com/topic/205774).

The best suggestion appears to be to look for common lock files, eg `vi foo` will make `.foo.swp` while `joe foo` will make `.#foo`.

So the question is, is there a better way to tell if a file is being edited? And if not, is there a list of all common lock file naming conventions?