"You don't want to have a number of scripts just looping while they wait to a file to get unlocked."
Why not?
Because those scripts will keep running (using the CPU) while they are not doing anything, Which is not good. What if the unlocking failed for some reason, you could end up with hundreds of scripts just eating your CPU for hours untill you notice.
Apart from that, what if one person locks the file, and keeps it locked for 15 minutes. Anybody who wants to update the file is forced to wait for 15 minutes, and a PHP script/browser will not wait that long, and give a timeout error.
My task is to write a csv file, but only one user can do it at a time.
I know this can be done with ASP, with response.application or something.
I wrote what the error was and on what line it was.
Yes, you said it was on line 26, but where is line 26?? You only gave a bit of pseudo code that is not 26 lines long.
Basically, I want to know how to unlock a file. I think I know how to lock it.
Is it possible to unlock a file?
Now that is a silly question that I refuse to answer :-)
You can avoid all the locking issues if you create a new file for each file you want to lock, and call it something like "filename.lock". If that file contains "yes", the file is locked. If it does not exist, or contains "no" the file is not locked.
That way you could add some date and time information in that file to see how long the file has been locked, to prevent naughty users from keeping your files locked forever.