summaryrefslogtreecommitdiff
path: root/term
diff options
context:
space:
mode:
authorMichael I. Bushnell <mib@gnu.org>1995-12-12 21:13:28 +0000
committerMichael I. Bushnell <mib@gnu.org>1995-12-12 21:13:28 +0000
commit8358591235639f6c49397026c5b2d086c24ec576 (patch)
treed2ab549e42bcd4ea2fae15a6cf63fe00a92b3974 /term
parent8bee6719783f3f86f88f1c0519dcfc09ef8096d3 (diff)
(pty_po_create_hook, pty_po_destroy_hook): New functions.
(ptyopen, nptyperopens): New variables.
Diffstat (limited to 'term')
-rw-r--r--term/ptyio.c33
1 files changed, 31 insertions, 2 deletions
diff --git a/term/ptyio.c b/term/ptyio.c
index 0d2455e3..5d6e6ceb 100644
--- a/term/ptyio.c
+++ b/term/ptyio.c
@@ -52,6 +52,7 @@ static int pktnostop;
static int ptyopen;
+static int nptyperopens;
static void
@@ -70,14 +71,42 @@ pty_open_hook (struct trivfs_control *cntl,
if ((flags & (O_READ|O_WRITE)) == 0)
return 0;
+ mutex_lock (&global_lock);
+
if (ptyopen)
- return EBUSY;
-
+ {
+ mutex_unlock (&global_lock);
+ return EBUSY;
+ }
+
pty_open = 1;
report_carrier_on ();
+ mutex_unlock (&global_lock);
return 0;
}
+error_t
+pty_po_create_hook (struct trivfs_peropen *po)
+{
+ mutex_lock (&global_lock);
+ nptyperopens++;
+ mutex_unlock (&global_lock);
+ return 0;
+}
+
+error_t
+pty_po_destroy_hook (struct trivfs_peropen *po)
+{
+ mutex_lock (&global_lock);
+ nptyperopens--;
+ if (!nptyperopns)
+ {
+ pty_open = 0;
+ report_carrier_off ();
+ }
+ mutex_unlock (&global_lock);
+ return 0;
+}
static inline void
wake_reader ()