JA
apps/winzik / tests / fixtures / relaunch-new.php · commit 6576d6f
<?php// The new WinZik of RelaunchTest: takes the lock as WinZik does (Relaunch::takeLock, 5 s), or says it could not.require __DIR__ . '/../../vendor/autoload.php';[, $lockFile, $result, $how] = $argv + [3 => 'relaunch'];if ($how === 'old') {    // the lock as before (no owner, no take-over)    $lock = fopen($lockFile, 'c+');    $until = microtime(true) + 5;    while (!flock($lock, LOCK_EX | LOCK_NB)) {        if (microtime(true) > $until) {            file_put_contents($result, 'blocked');            exit(1);        }        usleep(100000);    }    file_put_contents($result, 'started');    exit(0);}file_put_contents($result, \App\Core\Relaunch::takeLock($lockFile, 5.0) !== null ? 'started' : 'blocked');