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); } }