Proper exit code

This commit is contained in:
Daniil Gentili 2019-09-03 18:29:50 +02:00
parent 662c947953
commit d7c7445207
3 changed files with 8 additions and 6 deletions

2
docs

@ -1 +1 @@
Subproject commit 42b994bbe543269072dcefa4421bdb4b828d8235
Subproject commit 9a873608310b43395032755c35bbdf17d35e23d7

View File

@ -93,6 +93,6 @@ class Exception extends \Exception
public static function ExceptionHandler($exception)
{
Logger::log($exception, Logger::FATAL_ERROR);
Magic::shutdown();
Magic::shutdown(1);
}
}

View File

@ -161,11 +161,11 @@ class Magic
//if (function_exists('pcntl_async_signals')) pcntl_async_signals(true);
Loop::unreference(Loop::onSignal(SIGINT, static function () {
Logger::log('Got sigint', Logger::FATAL_ERROR);
Magic::shutdown();
Magic::shutdown(1);
}));
Loop::unreference(Loop::onSignal(SIGTERM, static function () {
Logger::log('Got sigterm', Logger::FATAL_ERROR);
Magic::shutdown();
Magic::shutdown(1);
}));
}
if (!self::$altervista && !self::$zerowebhost) {
@ -225,13 +225,15 @@ class Magic
/**
* Shutdown system.
*
* @param int $code Exit code
*
* @return void
*/
public static function shutdown()
public static function shutdown(int $code = 0)
{
self::$signaled = true;
getStdin()->unreference();
getInputBufferStream()->unreference();
die();
die($code);
}
}