summaryrefslogtreecommitdiff
path: root/term
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2022-08-22 01:19:45 +0200
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2022-08-22 01:19:45 +0200
commit4f653341476e7bd81475ea29316d59254d8b957e (patch)
tree5777da5f219c46bf21d7733f1ba3187fd5412cb7 /term
parentb1a00127663a9220d10febaaf48351f9f907ea80 (diff)
term: Prevent new master while some slaves are still there
The previous master may have gone before all previous slaves have gone. If a slave gets stuck, TTY_OPEN will kept set, and there would be no reset performed in open_hook, thus leaking tty state and data.
Diffstat (limited to 'term')
-rw-r--r--term/ptyio.c2
-rw-r--r--term/term.h2
2 files changed, 3 insertions, 1 deletions
diff --git a/term/ptyio.c b/term/ptyio.c
index fadddc16..928ae0ac 100644
--- a/term/ptyio.c
+++ b/term/ptyio.c
@@ -72,7 +72,7 @@ pty_open_hook (struct trivfs_control *cntl,
pthread_mutex_lock (&global_lock);
- if (ptyopen)
+ if (ptyopen || nperopens)
{
pthread_mutex_unlock (&global_lock);
return EBUSY;
diff --git a/term/term.h b/term/term.h
index 162ed49d..efe27ffa 100644
--- a/term/term.h
+++ b/term/term.h
@@ -31,6 +31,8 @@
#include <features.h>
#include <hurd/hurd_types.h>
+extern int nperopens;
+
#ifdef TERM_DEFINE_EI
#define TERM_EI
#else