term: shutdown: special case child terminating due to SIGHUP

When closing the window via a compositor shortcut, or clicking the CSD
close button, we kill the client application by sending it SIGHUP (and
then SIGTERM followed by SIGKILL, if it refuses to die).

Many shells either don't catch SIGHUP, causing us to exit with a
non-zero value, or they catch it, and then _they_ exit with a non-zero
value, causing _us_ to propagate that to the user.

This patch changes foot's behavior to "ignore" death-by-sighup, and
always exit with value 0.

The log message is changed to debug level, for SIGHUP only; other
death-by-signal is still logged at the warning level.
This commit is contained in:
Daniel Eklöf 2025-02-03 07:50:10 +01:00
parent 51128a3484
commit cbe1c2fe75
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F
2 changed files with 8 additions and 1 deletions

View file

@ -72,6 +72,9 @@
* Do not try to set a zero width, or height, if the compositor sends a
_configure_ event with only one dimension being zero
([#1925][1925]).
* Exit with value `0` when the client process exits due to us sending
it `SIGHUP`. This happens for example when closing the window with
either a compositor shortcut, or clicking the CSD _close_ button.
[1925]: https://codeberg.org/dnkl/foot/issues/1925

View file

@ -1978,6 +1978,10 @@ term_destroy(struct terminal *term)
LOG_DBG("slave exited with code %d", ret);
} else if (WIFSIGNALED(exit_status)) {
ret = WTERMSIG(exit_status);
if (ret == SIGHUP) {
LOG_DBG("slave exited with signal %d (%s)", ret, strsignal(ret));
ret = 0;
} else
LOG_WARN("slave exited with signal %d (%s)", ret, strsignal(ret));
} else {
LOG_WARN("slave exited for unknown reason (status = 0x%08x)",