From a1b41bd186147f3f028030e9079821d0bfa7b3f6 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Fri, 30 Apr 2021 22:47:16 +0200 Subject: foot/footclient: use a custom exit code when foot/footclient fail to run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Normally, foot and footclient uses the exit code from the client application (i.e. the shell). However, foot (or footclient) itself may fail to run; if run outside of a Wayland session, or no fonts are installed, or the client application/shell cannot be found (“foot lsdjfldsjf”) etc. Up until now, there has been no way to differentiate these kind of failures from the client application exiting with code 1. This patch changes foot’s failure exit code to -27/229, and footclient’s to -28/228. Note that footclient will exit with foot’s -27/229 if footclient ran successfully, but the foot server failed to instantiate a new window. Closes #466. --- server.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'server.c') diff --git a/server.c b/server.c index 2d813ab2..6a86bae2 100644 --- a/server.c +++ b/server.c @@ -312,7 +312,7 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data) if (instance->terminal == NULL) { LOG_ERR("failed to instantiate new terminal"); - client_send_exit_code(client, -1); + client_send_exit_code(client, -27); instance_destroy(instance, -1); goto shutdown; } @@ -497,7 +497,7 @@ server_destroy(struct server *server) tll_length(server->clients)); tll_foreach(server->clients, it) { - client_send_exit_code(it->item, 1); + client_send_exit_code(it->item, -27); client_destroy(it->item); } -- cgit v1.3 From da923100cad1000252c87b02a4132ce5878a28ec Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 1 May 2021 10:46:40 +0200 Subject: main/client: change exit code * foot exits with -26/230 * footclient exits with -36/220 This is to give each application a range of exit codes. Currently unused, but we may want to change this in the future. --- CHANGELOG.md | 6 +++--- client.c | 2 +- main.c | 2 +- server.c | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'server.c') diff --git a/CHANGELOG.md b/CHANGELOG.md index 5dbe40e3..7ec26157 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -51,10 +51,10 @@ * Point values in `line-height`, `letter-spacing`, `horizontal-letter-offset` and `vertical-letter-offset` are now rounded, not truncated, when translated to pixel values. -* Foot’s exit code is now -27/229 when foot itself failed to launch +* Foot’s exit code is now -26/230 when foot itself failed to launch (due to invalid command line options, client application/shell not - found etc). Footclient’s exit code is -28/228 when it itself fails - to launch (e.g. bad command line option) and -27/229 when the foot + found etc). Footclient’s exit code is -36/220 when it itself fails + to launch (e.g. bad command line option) and -26/230 when the foot server failed to instantiate a new window (https://codeberg.org/dnkl/foot/issues/466). diff --git a/client.c b/client.c index 388f816e..1445146c 100644 --- a/client.c +++ b/client.c @@ -71,7 +71,7 @@ main(int argc, char *const *argv) { /* Custom exit code, to enable users to differentiate between foot * itself failing, and the client application failiing */ - static const int foot_exit_failure = -28; + static const int foot_exit_failure = -36; int ret = foot_exit_failure; const char *const prog_name = argv[0]; diff --git a/main.c b/main.c index 573cb0a1..82795424 100644 --- a/main.c +++ b/main.c @@ -153,7 +153,7 @@ main(int argc, char *const *argv) { /* Custom exit code, to enable users to differentiate between foot * itself failing, and the client application failiing */ - static const int foot_exit_failure = -27; + static const int foot_exit_failure = -26; int ret = foot_exit_failure; /* Startup notifications; we don't support it, but must ensure we diff --git a/server.c b/server.c index 6a86bae2..1b33ee23 100644 --- a/server.c +++ b/server.c @@ -312,7 +312,7 @@ fdm_client(struct fdm *fdm, int fd, int events, void *data) if (instance->terminal == NULL) { LOG_ERR("failed to instantiate new terminal"); - client_send_exit_code(client, -27); + client_send_exit_code(client, -26); instance_destroy(instance, -1); goto shutdown; } @@ -497,7 +497,7 @@ server_destroy(struct server *server) tll_length(server->clients)); tll_foreach(server->clients, it) { - client_send_exit_code(it->item, -27); + client_send_exit_code(it->item, -26); client_destroy(it->item); } -- cgit v1.3