From 98e11f18b40af3c684db47613b0afdb15c6eabbc Mon Sep 17 00:00:00 2001
From: Miles Bader <miles@gnu.org>
Date: Wed, 2 Oct 1996 15:59:20 +0000
Subject: (S_tioctl_tiocsig, S_tioctl_tiocucntl, S_tioctl_tiocpkt):   Hold
 GLOBAL_LOCK while frobbing (especially around send_signal).

---
 term/ptyio.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

(limited to 'term')

diff --git a/term/ptyio.c b/term/ptyio.c
index 22c46407..16f5d08b 100644
--- a/term/ptyio.c
+++ b/term/ptyio.c
@@ -464,12 +464,17 @@ S_tioctl_tiocsig (io_t port,
   if (!cred)
     return EOPNOTSUPP;
   
+  mutex_lock (&global_lock);
+
   drop_output ();
   clear_queue (inputq);
   clear_queue (rawq);
   ptyio_notice_input_flushed ();
   send_signal (sig);
+
+  mutex_unlock (&global_lock);
   ports_port_deref (cred);
+
   return 0;
 }
 
@@ -484,6 +489,8 @@ S_tioctl_tiocpkt (io_t port,
   if (!cred)
     return EOPNOTSUPP;
   
+  mutex_lock (&global_lock);
+
   if (!!mode == !!packet_mode)
     err = 0;
   else if (mode && user_ioctl_mode)
@@ -494,7 +501,10 @@ S_tioctl_tiocpkt (io_t port,
       control_byte = 0;
       err = 0;
     }
+
+  mutex_unlock (&global_lock);
   ports_port_deref (cred);
+
   return err;
 }
 
@@ -509,6 +519,8 @@ S_tioctl_tiocucntl (io_t port,
   if (!cred)
     return EOPNOTSUPP;
   
+  mutex_lock (&global_lock);
+
   if (!!mode == !!user_ioctl_mode)
     err = 0;
   else if (mode && packet_mode)
@@ -519,7 +531,10 @@ S_tioctl_tiocucntl (io_t port,
       control_byte = 0;
       err = 0;
     }
+
+  mutex_unlock (&global_lock);
   ports_port_deref (cred);
+
   return err;
 }
 
-- 
cgit v1.2.3