file
file copied to clipboard
FileMutex does not release mutex if process is killed
<?php
use Amp\File\FileMutex;
require 'vendor/autoload.php';
$pid = pcntl_fork();
if ($pid) {
sleep(1);
posix_kill($pid, 9);
var_dump("killed");
var_dump("Trying to re-acquire lock");
$lock = new FileMutex('/tmp/test');
$lock->acquire();
var_dump("unreachable");
} else {
$lock = new FileMutex('/tmp/test');
$lock->acquire();
var_dump("Acquired lock!");
}
using flock instead of just file creation like in https://github.com/danog/MadelineProto/blob/v8/src/AsyncTools.php#L83 should fix the issue.