From 8fa16f616c4ae963f77febe30e6aa167f389b162 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Wed, 16 Feb 2022 22:40:51 +0100 Subject: [PATCH] =?UTF-8?q?main:=20--server:=20don=E2=80=99t=20exit=20with?= =?UTF-8?q?=20code=200=20on=20failure?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A foot --server instance would exit with code 0, even on failure, if the number of currently open terminal instances were 0. This is because ‘ret’ assumed failure, and then tried to set it to ‘success’ after the even loop had terminated, basted on the server’s current state. Fix by: * set ‘ret’ to success just before entering the event loop * set ‘ret’ to failure when we detect an FDM failure * don’t try to second-guess success/failure after having exited the event loop Closes #943 --- CHANGELOG.md | 3 +++ main.c | 8 ++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ac9247e5..ab8d4b81 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,6 +69,9 @@ (https://codeberg.org/dnkl/foot/issues/924). * Crash in `pipe-scrollback` (https://codeberg.org/dnkl/foot/issues/926). +* Exit code being 0 when a foot server with no open windows terminate + due to e.g. a Wayland connection failure + (https://codeberg.org/dnkl/foot/issues/943). ### Security diff --git a/main.c b/main.c index ff839507..4011dcde 100644 --- a/main.c +++ b/main.c @@ -642,14 +642,14 @@ main(int argc, char *const *argv) goto out; } + ret = EXIT_SUCCESS; while (likely(!aborted && (as_server || tll_length(wayl->terms) > 0))) { - if (unlikely(!fdm_poll(fdm))) + if (unlikely(!fdm_poll(fdm))) { + ret = foot_exit_failure; break; + } } - if (aborted || tll_length(wayl->terms) == 0) - ret = EXIT_SUCCESS; - out: free(_cwd); server_destroy(server);