aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2024-04-05 14:22:42 +0000
committerDaniel Eklöf <daniel@ekloef.se>2024-04-05 16:45:31 +0000
commitc7848c4e75c3cb5704378137c5b5c989135f81b1 (patch)
tree7a14e86284528816f00a7a25041f7b05a9330779
parentwayland: only use the surface preferred scale if set by the compositor (diff)
term: don't shutdown terminal when PTY is closed, unless --pty was used
Unless --pty has been used, we do *not* want to shutdown the terminal when the PTY is closed by the client application; we want to wait for the client application to actually terminate. This was the behavior before the --pty patch. This was changed in the --pty patch, since then, we don't *have* a client application. That is, foot has not forked+exec:ed anything. The only way to trigger a shutdown (from the client side) is to close the PTY. This patch restores the old behavior, when --pty is *not* used. Closes #1666
-rw-r--r--CHANGELOG.md5
-rw-r--r--terminal.c14
2 files changed, 18 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 4ff49390..66d6dc42 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -58,6 +58,11 @@
### Fixed
* Log-level not respected by syslog.
+* Regression: terminal shutting down when the PTY is closed by the
+ client application, which may be earlier than when the client
+ application exits ([#1666][1666]).
+
+[1666]: https://codeberg.org/dnkl/foot/issues/1666
### Security
diff --git a/terminal.c b/terminal.c
index 6144bacb..acb5a639 100644
--- a/terminal.c
+++ b/terminal.c
@@ -364,8 +364,20 @@ fdm_ptmx(struct fdm *fdm, int fd, int events, void *data)
del_utmp_record(term->conf, term->reaper, term->ptmx);
fdm_del(fdm, fd);
term->ptmx = -1;
- if (!term->conf->hold_at_exit)
+
+ /*
+ * Normally, we do *not* want to shutdown when the PTY is
+ * closed. Instead, we want to wait for the client application
+ * to exit.
+ *
+ * However, when we're using a pre-existing PTY (the --pty
+ * option), there _is_ no client application. That is, foot
+ * does *not* fork+exec anything, and thus the only way to
+ * shutdown is to wait for the PTY to be closed.
+ */
+ if (term->slave < 0 && !term->conf->hold_at_exit) {
term_shutdown(term);
+ }
}
return true;