From ee81057e44687ccb790be2322b582beec633a3e5 Mon Sep 17 00:00:00 2001 From: Jephte Clain Date: Wed, 25 Sep 2024 17:21:56 +0400 Subject: [PATCH] modifs.mineures sans commentaires --- wip/app/app2.php | 9 ++++++++- wip/app/cli/Application.php | 6 +++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/wip/app/app2.php b/wip/app/app2.php index fc667f9..f38f874 100644 --- a/wip/app/app2.php +++ b/wip/app/app2.php @@ -476,12 +476,19 @@ class app2 { ############################################################################# + const EC_LOCKED = 252; + const EC_BAD_COMMAND = 253; + const EC_EXCEPTION = 254; + const EC_SIGNAL = 255; + + ############################################################################# + static bool $dispach_signals = false; static function install_signal_handler(bool $allow=true): void { if (!$allow) return; $signalHandler = function(int $signo, $siginfo) { - throw new ExitError(255); + throw new ExitError(self::EC_SIGNAL); }; pcntl_signal(SIGHUP, $signalHandler); pcntl_signal(SIGINT, $signalHandler); diff --git a/wip/app/cli/Application.php b/wip/app/cli/Application.php index 62ee7ad..4113412 100644 --- a/wip/app/cli/Application.php +++ b/wip/app/cli/Application.php @@ -105,7 +105,7 @@ abstract class Application { break; default: fwrite(STDERR, "$argv[2]: unexpected command\n"); - $ec = 123; + $ec = app2::EC_BAD_COMMAND; } exit($ec); } @@ -132,7 +132,7 @@ abstract class Application { $runfile = app2::get()->getRunfile(); self::_manage_runfile($runfile); - if ($useRunlock && $runfile->warnIfLocked()) exit(1); + if ($useRunlock && $runfile->warnIfLocked()) exit(app2::EC_LOCKED); $runfile->wfStart(); $stop = true; @@ -149,7 +149,7 @@ abstract class Application { exit($e->getCode()); } catch (Exception $e) { msg::error($e); - exit(1); + exit(app2::EC_EXCEPTION); } }