From 015221eafb429809a2d9b817c12e65235b57cd59 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 27 Nov 2023 19:34:14 +0200 Subject: [PATCH] fix semaphore condition #5 --- src/cli/document/clean.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/cli/document/clean.php b/src/cli/document/clean.php index 5ca5672..a7ae1ba 100644 --- a/src/cli/document/clean.php +++ b/src/cli/document/clean.php @@ -3,6 +3,11 @@ // Prevent multi-thread execution $semaphore = sem_get(crc32('yo.cli.document.clean'), 1); +if (false === sem_acquire($semaphore, true)) +{ + exit ('process execution locked by another thread!' . PHP_EOL); +} + // Load dependencies require_once __DIR__ . '/../../../vendor/autoload.php';