aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2022-02-16 21:40:51 +0000
committerDaniel Eklöf <daniel@ekloef.se>2022-02-16 21:44:42 +0000
commit8fa16f616c4ae963f77febe30e6aa167f389b162 (patch)
tree44c75f591fc30b581d5c66fa1a453502f8244933
parentMerge branch 'terminfo-sync-2026' (diff)
main: --server: don’t exit with code 0 on failure
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
-rw-r--r--CHANGELOG.md3
-rw-r--r--main.c8
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);