Answer the question
In order to leave comments, you need to log in
How to explain such behavior?
Now I screwed on the old proven blocking of the launch of an already running script and it didn’t work, I found the reason by typing, but now I wonder why this
is the working option
<?php
$lockFile = fopen('running.lock', 'w');
function isRunning($lockFile)
{
return !flock($lockFile, LOCK_EX | LOCK_NB);
}
if (isRunning($lockFile)) {
die('running' . PHP_EOL);
} else {
// ...
sleep(5);
}
<?php
function isRunning()
{
$lockFile = fopen('running.lock', 'w');
return !flock($lockFile, LOCK_EX | LOCK_NB);
}
if (isRunning()) {
die('running' . PHP_EOL);
} else {
// ...
sleep(5);
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question