Results 1 to 4 of 4
Thread: php persistant flock()ing ?
-
04-14-2005, 09:46 AM #1Junior Guru
- Join Date
- Nov 2002
- Posts
- 202
php persistant flock()ing ?
Hello, is it possible to flock() a file, and keep the lock on the file even after the script terminates?
-
04-14-2005, 11:06 AM #2Aspiring Evangelist
- Join Date
- Jun 2002
- Posts
- 351
Unfortunatly, not in an easy mannor.
PHP automagicly releases the lock when the script ends so your only option would be to edit the PHP source code to stop it doing this and compile your own custom version of PHP.
Even that might not work though, I'm afraid I don't know enough about file locking to say for sure.
Thanks,
Alan.
-
04-14-2005, 09:53 PM #3Web Hosting Master
- Join Date
- Mar 2002
- Location
- New York
- Posts
- 1,700
Why not do it server side using shell_exec() in PHP? Create a bash script to lock the file, and unlock the file.
Run the script via PHP
$exec = shell_exec("lock_file.sh");
After the script is executed, it will still be locked. then later, just unlock it with another bash script.
-
04-14-2005, 10:06 PM #4Junior Guru
- Join Date
- Nov 2002
- Posts
- 202
thats exactly what i will do. i was thinking in C, but now that u mention it. excellent!
btw, can i get php to wait for a lock with flock()? i havent used it before..