From 8358591235639f6c49397026c5b2d086c24ec576 Mon Sep 17 00:00:00 2001 From: "Michael I. Bushnell" Date: Tue, 12 Dec 1995 21:13:28 +0000 Subject: (pty_po_create_hook, pty_po_destroy_hook): New functions. (ptyopen, nptyperopens): New variables. --- term/ptyio.c | 33 +++++++++++++++++++++++++++++++-- 1 file 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 () -- cgit v1.2.3