summaryrefslogtreecommitdiffstats
path: root/winsup/cygwin/fhandler_tty.cc
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2015-03-05 13:58:03 +0000
committerCorinna Vinschen <corinna@vinschen.de>2015-03-05 13:58:03 +0000
commit5e99eb1104f49b6d1e88ea09e8bac734fe668bb3 (patch)
tree2392a6ef97e610a326cd9697234c4ac9275c449c /winsup/cygwin/fhandler_tty.cc
parent3bf693dde14b17e78ff99a0d04baf71841ae884c (diff)
downloadcygnal-5e99eb1104f49b6d1e88ea09e8bac734fe668bb3.tar.gz
cygnal-5e99eb1104f49b6d1e88ea09e8bac734fe668bb3.tar.bz2
cygnal-5e99eb1104f49b6d1e88ea09e8bac734fe668bb3.zip
* tty.h (tty::set_master_ctl_closed): Rename from set_master_closed.
(tty::is_master_closed): Drop method. * fhandler_tty.cc (fhandler_pty_slave::open): Remove code prematurely bailing out if master control thread is not running. (fhandler_pty_slave::read): Don't generate SIGHUP if master control thread is not running. (fhandler_pty_master::close): Rearrange code to avoid stopping master control thread twice in multi-threaded scenarios.
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r--winsup/cygwin/fhandler_tty.cc31
1 files changed, 11 insertions, 20 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 39fe6dffc..c7c90e28d 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -462,12 +462,6 @@ fhandler_pty_slave::open (int flags, mode_t)
goto err_no_errno;
}
- if (get_ttyp ()->is_master_closed ())
- {
- errmsg = "*** master is closed";
- set_errno (EAGAIN);
- goto err_no_errno;
- }
/* Three case for duplicating the pipe handles:
- Either we're the master. In this case, just duplicate the handles.
- Or, we have the right to open the master process for handle duplication.
@@ -744,12 +738,6 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
switch (cygwait (input_available_event, time_to_wait))
{
case WAIT_OBJECT_0:
- if (get_ttyp ()->is_master_closed ())
- {
- raise (SIGHUP);
- totalread = 0;
- goto out;
- }
break;
case WAIT_SIGNALED:
if (totalread > 0)
@@ -1315,9 +1303,17 @@ fhandler_pty_master::close ()
__small_sprintf (buf, "\\\\.\\pipe\\cygwin-%S-pty%d-master-ctl",
&cygheap->installation_key, get_minor ());
- CallNamedPipe (buf, &req, sizeof req, &repl, sizeof repl, &len, 500);
- CloseHandle (master_ctl);
- master_thread->detach ();
+ acquire_output_mutex (INFINITE);
+ if (master_ctl)
+ {
+ CallNamedPipe (buf, &req, sizeof req, &repl, sizeof repl, &len,
+ 500);
+ CloseHandle (master_ctl);
+ master_thread->detach ();
+ get_ttyp ()->set_master_ctl_closed ();
+ master_ctl = NULL;
+ }
+ release_output_mutex ();
}
}
@@ -1334,11 +1330,6 @@ fhandler_pty_master::close ()
if (have_execed || get_ttyp ()->master_pid != myself->pid)
termios_printf ("not clearing: %d, master_pid %d", have_execed, get_ttyp ()->master_pid);
- else
- {
- get_ttyp ()->set_master_closed ();
- SetEvent (input_available_event);
- }
if (!ForceCloseHandle (input_available_event))
termios_printf ("CloseHandle (input_available_event<%p>), %E", input_available_event);