From 4c8029fce6a15a4a914c995536fc3ea978b932ef Mon Sep 17 00:00:00 2001 From: Shish Date: Fri, 5 Jan 2024 16:30:54 +0000 Subject: [PATCH] [cli] exit non-zero if there's a fatal error --- index.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/index.php b/index.php index 7a4d9b03..ec82cc1a 100644 --- a/index.php +++ b/index.php @@ -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); +}