replace all instances of die() with print+exit because die() returns exit code 0

This commit is contained in:
Andrew Dolgov 2025-07-04 13:31:15 +03:00
parent b0dc82dc7e
commit ec0a19c5a6
No known key found for this signature in database
GPG Key ID: 1A56B4FA25D4AF2A
3 changed files with 18 additions and 9 deletions

View File

@ -73,7 +73,8 @@ class RSSUtils {
if (!$limit) $limit = Config::get(Config::DAEMON_FEED_LIMIT); if (!$limit) $limit = Config::get(Config::DAEMON_FEED_LIMIT);
if (Config::get_schema_version() != Config::SCHEMA_VERSION) { if (Config::get_schema_version() != Config::SCHEMA_VERSION) {
die("Schema version is wrong, please upgrade the database.\n"); print("Schema version is wrong, please upgrade the database.\n");
exit(1);
} }
self::init_housekeeping_tasks(); self::init_housekeeping_tasks();

View File

@ -141,7 +141,8 @@
} }
if (!isset($options['update-schema']) && Config::is_migration_needed()) { if (!isset($options['update-schema']) && Config::is_migration_needed()) {
die("Schema version is wrong, please upgrade the database (--update-schema).\n"); print("Schema version is wrong, please upgrade the database (--update-schema).\n");
exit(1);
} }
Debug::set_enabled(true); Debug::set_enabled(true);
@ -188,8 +189,9 @@
// Try to lock a file in order to avoid concurrent update. // Try to lock a file in order to avoid concurrent update.
if (!$lock_handle) { if (!$lock_handle) {
die("error: Can't create lockfile ($lock_filename). ". print("error: Can't create lockfile ($lock_filename). ".
"Maybe another update process is already running.\n"); "Maybe another update process is already running.\n");
exit(1);
} }
if (isset($options["force-update"])) { if (isset($options["force-update"])) {

View File

@ -13,16 +13,18 @@
Config::sanity_check(); Config::sanity_check();
if (!function_exists('pcntl_fork')) { if (!function_exists('pcntl_fork')) {
die("error: This script requires PHP compiled with PCNTL module.\n"); print("error: This script requires PHP compiled with PCNTL module.\n");
exit(1);
} }
$options = getopt(""); $options = getopt("");
if (!is_array($options)) { if (!is_array($options)) {
die("error: getopt() failed. ". print("error: getopt() failed. ".
"Most probably you are using PHP CGI to run this script ". "Most probably you are using PHP CGI to run this script ".
"instead of required PHP CLI. Check tt-rss wiki page on updating feeds for ". "instead of required PHP CLI. Check tt-rss wiki page on updating feeds for ".
"additional information.\n"); "additional information.\n");
exit(1);
} }
@ -188,20 +190,23 @@
} }
if (file_is_locked("update_daemon.lock")) { if (file_is_locked("update_daemon.lock")) {
die("error: Can't create lockfile. ". print("error: Can't create lockfile. ".
"Maybe another daemon is already running.\n"); "Maybe another daemon is already running.\n");
exit(1);
} }
// Try to lock a file in order to avoid concurrent update. // Try to lock a file in order to avoid concurrent update.
$lock_handle = make_lockfile("update_daemon.lock"); $lock_handle = make_lockfile("update_daemon.lock");
if (!$lock_handle) { if (!$lock_handle) {
die("error: Can't create lockfile. ". print("error: Can't create lockfile. ".
"Maybe another daemon is already running.\n"); "Maybe another daemon is already running.\n");
exit(1);
} }
if (Config::is_migration_needed()) { if (Config::is_migration_needed()) {
die("Schema version is wrong, please upgrade the database.\n"); print("Schema version is wrong, please upgrade the database.\n");
exit(1);
} }
// Protip: children close shared database handle when terminating, it's a bad idea to // Protip: children close shared database handle when terminating, it's a bad idea to
@ -225,7 +230,8 @@
for ($j = count($children); $j < $max_jobs; $j++) { for ($j = count($children); $j < $max_jobs; $j++) {
$pid = pcntl_fork(); $pid = pcntl_fork();
if ($pid == -1) { if ($pid == -1) {
die("fork failed!\n"); print("fork failed!\n");
exit(1);
} else if ($pid) { } else if ($pid) {
if (!$master_handlers_installed) { if (!$master_handlers_installed) {