aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/fhandler/pty.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/fhandler/pty.cc')
-rw-r--r--winsup/cygwin/fhandler/pty.cc33
1 files changed, 33 insertions, 0 deletions
diff --git a/winsup/cygwin/fhandler/pty.cc b/winsup/cygwin/fhandler/pty.cc
index e61a1c8..b882b90 100644
--- a/winsup/cygwin/fhandler/pty.cc
+++ b/winsup/cygwin/fhandler/pty.cc
@@ -1304,6 +1304,15 @@ fhandler_pty_slave::read (void *ptr, size_t& len)
push_process_state process_state (PID_TTYIN);
+ if (get_ttyp ()->input_stopped && is_nonblocking ())
+ {
+ set_errno (EAGAIN);
+ len = (size_t) -1;
+ return;
+ }
+ while (get_ttyp ()->input_stopped)
+ cygwait (10);
+
if (ptr) /* Indicating not tcflush(). */
mask_switch_to_nat_pipe (true, true);
@@ -1650,6 +1659,7 @@ fhandler_pty_slave::ioctl (unsigned int cmd, void *arg)
retval = this->tcsetpgrp ((pid_t) (intptr_t) arg);
goto out;
case FIONREAD:
+ case TIOCINQ:
{
DWORD n;
if (!bytes_available (n))
@@ -1664,6 +1674,12 @@ fhandler_pty_slave::ioctl (unsigned int cmd, void *arg)
}
}
goto out;
+ case TCXONC:
+ retval = this->tcflow ((int)(intptr_t) arg);
+ goto out;
+ case TCFLSH:
+ retval = this->tcflush ((int)(intptr_t) arg);
+ goto out;
default:
return fhandler_base::ioctl (cmd, arg);
}
@@ -1933,7 +1949,10 @@ int
fhandler_pty_master::open (int flags, mode_t)
{
if (!setup ())
+ {
+ set_errno (EMFILE);
return 0;
+ }
set_open_status ();
dwProcessId = GetCurrentProcessId ();
return 1;
@@ -2339,6 +2358,7 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
case TIOCSPGRP:
return this->tcsetpgrp ((pid_t) (intptr_t) arg);
case FIONREAD:
+ case TIOCINQ:
{
DWORD n;
if (!bytes_available (n))
@@ -2349,6 +2369,10 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
*(int *) arg = (int) n;
}
break;
+ case TCXONC:
+ return this->tcflow ((int)(intptr_t) arg);
+ case TCFLSH:
+ return this->tcflush ((int)(intptr_t) arg);
default:
return fhandler_base::ioctl (cmd, arg);
}
@@ -4191,3 +4215,12 @@ fhandler_pty_common::resume_from_temporarily_attach (DWORD resume_pid)
}
release_attach_mutex ();
}
+
+int
+fhandler_pty_common::tcdrain ()
+{
+ DWORD n;
+ while (bytes_available (n) && n > 0)
+ cygwait (10);
+ return 0;
+}