aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2020-12-26 00:35:17 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-01-21 10:44:06 +0000
commit981fb0a755f3fb29c5634d3050492426f26f97c9 (patch)
treefbc551ad4b7720511a8a096769c394a0df09c425
parentterminal: shutdown (or --hold) when the client process terminates (diff)
terminal: reaper callback: don’t close ptmx if already closed
-rw-r--r--terminal.c7
1 files 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;
}