From 0dbd85ed9e76447917ec58b83a15c99258bebab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sat, 26 Dec 2020 01:35:17 +0100 Subject: [PATCH] =?UTF-8?q?terminal:=20reaper=20callback:=20don=E2=80=99t?= =?UTF-8?q?=20close=20ptmx=20if=20already=20closed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- terminal.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/terminal.c b/terminal.c index 78969e9e..ecb4e6cc 100644 --- a/terminal.c +++ b/terminal.c @@ -957,8 +957,11 @@ slave_died(struct reaper *reaper, pid_t pid, void *data) LOG_DBG("slave (PID=%u) died", pid); if (term->conf->hold_at_exit) { - fdm_del(term->fdm, term->ptmx); - term->ptmx = -1; + /* The PTMX FDM handler may already have closed our end */ + if (term->ptmx >= 0) { + fdm_del(term->fdm, term->ptmx); + term->ptmx = -1; + } return true; }