[cli] exit non-zero if there's a fatal error

This commit is contained in:
Shish
2024-01-05 16:30:54 +00:00
parent 880313ec4a
commit 4c8029fce6

View File

@@ -91,11 +91,13 @@ try {
if (function_exists("fastcgi_finish_request")) {
fastcgi_finish_request();
}
$exit_code = 0;
} catch (Exception $e) {
if ($database && $database->is_transaction_open()) {
$database->rollback();
}
_fatal_error($e);
$exit_code = 1;
} finally {
$_tracer->end();
if (TRACE_FILE) {
@@ -111,3 +113,6 @@ try {
}
}
}
if (PHP_SAPI === 'cli' || PHP_SAPI == 'phpdbg') {
exit($exit_code);
}