You don't want to unlink your lockfiles. In UNIX, it's possible to unlink a file that's opened by another process, so you can get this sequence:
- Process A creates, opens and locks lockfile
- Process B opens lockfile, tries to lock it, and blocks
- Process A unlocks and unlinks lockfile
- Process B locks the now-unlinked lockfile
- Process C creates, opens and locks a new lockfile
At this point, both B and C think they have exclusive access to the resource. It is very easy to cause this situation to occur. Doing the unlink before the unlock doesn't help; the problem is that B is still trying to lock the old file that A unlinked. Don't unlink lockfiles unless you're into pain. Just leave them there.