Error-prone file locking : touch « File Directory « PHP
- PHP
- File Directory
- touch
Error-prone file locking
<?
$locked = 0;
while (! $locked) {
if (! file_exists('guestbook.txt.lock')) {
touch('guestbook.txt.lock');
$locked = 1;
} else {
sleep(1);
}
}
?>
Related examples in the same category