From 329f2a488c6b9f3b9b8e9ff940c58d8564ae9f5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Fri, 12 Mar 2021 22:06:50 +0100 Subject: [PATCH] =?UTF-8?q?term:=20don=E2=80=99t=20close=20PTY=20when=20cl?= =?UTF-8?q?ient=20application=20dies?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closing it as soon as we detect that the client has died, means we may not have drained it completely. The PTY is either closed _by_ the client application, or by us when we shutdown the terminal. Thus, leaving it open (until we call term_shutdown()) is fine. --- CHANGELOG.md | 1 + terminal.c | 12 ++---------- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a6c03b88..8cf22411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -108,6 +108,7 @@ exiting shell (https://codeberg.org/dnkl/foot/issues/366). * Default value of `-t,--term` in `--help` output when foot was built without terminfo support. +* Drain PTY when the client application terminates. ### Security diff --git a/terminal.c b/terminal.c index 5cbb7fcf..88599094 100644 --- a/terminal.c +++ b/terminal.c @@ -991,16 +991,8 @@ slave_died(struct reaper *reaper, pid_t pid, int status, void *data) term->slave_has_been_reaped = true; term->exit_status = status; - if (term->conf->hold_at_exit) { - /* The PTMX FDM handler may already have closed our end */ - if (term->ptmx >= 0) { - fdm_del(term->fdm, term->ptmx); - term->ptmx = -1; - } - return; - } - - term_shutdown(term); + if (!term->conf->hold_at_exit) + term_shutdown(term); } struct terminal *