Reply to flock won't non-block at all

Your name:

Reply:


Posted by sven.holcombe on 09/21/06 02:44

Hi there,

I'm trying to just prevent multiple instances of a script running.

I would have thought that the following code would do this for me.

<php
$fp = fopen("foo.txt", "w");
flock($fp, LOCK_EX + LOCK_NB) or die ("Could not get lock!\n");
echo "Got lock!\n";
sleep(10);
flock($fp, LOCK_UN);
?>

The first script to run would obtain the lock on the file, and would
execute.
Any other scripts would fail immediately (because of my non-blocking
LOCK_NB).

But it seems that ALL of my scripts just wait, and ALL of them end up
printing "Got lock!"

Can anyone help me out?

I am on winXP with php5.

Cheers,
Sven.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация