A better thing to do would be, the next time it hangs,
to do lsof lockfile (if you're on an OS that supports
this), to see what process(es) still have the lock file open.
Unless you have a very screwed-up OS, a process must
habe an open file descriptor on a file to hold a lock. | [reply] [d/l] |
Are you sure the program terminates? If a program hangs for some reason, no other program can continue, but removing the lockfile will "solve" the problem (well, not the problem - just the symptom, and it might cause data corruption - you are using locking for a reason).
If all the programs that hold the lock terminate, and the file is still locked, the fault lies in your kernel, not in perl. It should be impossible for a file to be locked, without a locking process.
Abigail | [reply] |
My apologies, but the lock in my code is actually LOCK_EX (I copied the code directly from the book instead of from my program).
Don't do that. Copy and paste your actual code. Your problem may be some really subtle thing in your code, not the book.
Unfortunately I've never witnessed the last run of the program before it stops, so I've no idea how it dies. I'm just assuming that it's the lockfile because as soon as I delete it all other programs run freely again.
Huh? What do you mean "the last run of the program before it stops"? If it doesn't stop, why do you think it closes the file? Or do you mean that there are several processes all running the same code? When you say "all other programs", do you mean all other processes running the same code, or processes running different code? If it is different code, you need to post that, too.
| [reply] |