3 Answers
3

As Rabarberski says, lsof can be used to find any process that has the file open. Note that you need to run the program as root, i.e., using sudo, and that you can give the pathname to the file you're interested in as an argument, so there is no need for the grep invocation in the hint that Rabarberski points to. Also, if a process holds a lock on the file, you're supposed to be able to see that from the FD column in the lsof output. See the manual page for the details. (When I run sudo lsof on my machine, I see no locked files, so I won't guarantee that this works right on the Mac. sudo is after all a generic unix program, and conceivably some features don't work on OSX.)

You cannot unlock a file without killing the process that holds the lock. But you can remove it with rm from the command line.

Just noted a silly misprint: Where it says “sudo is after all …” it was lsof I had intended to mention. Not going to edit it – it's too minor to warrant a bump to the front page.
–
Harald Hanche-OlsenOct 30 '14 at 15:44