diff options
author | Christopher Faylor <me@cgf.cx> | 2000-05-12 05:06:43 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2000-05-12 05:06:43 +0000 |
commit | ad0bed746deb4fe28e55bf0be80e396464312444 (patch) | |
tree | 42356bb820d04b13e63ebc5c0dbbe2d8032710e9 /winsup/cygwin/fhandler_tty.cc | |
parent | cfe11d7465d410cd281f0cdf3296545c0243be2b (diff) | |
download | cygnal-ad0bed746deb4fe28e55bf0be80e396464312444.tar.gz cygnal-ad0bed746deb4fe28e55bf0be80e396464312444.tar.bz2 cygnal-ad0bed746deb4fe28e55bf0be80e396464312444.zip |
* Makefile.in (DLL_OFILES): Sort.
* fhandler_tty.cc (fhandler_tty_slave::send_ioctl_request): Eliminate.
(fhandler_tty_slave::ioctl): Rewrite to avoid races.
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 54 |
1 files changed, 31 insertions, 23 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index ef031b10f..5f1fc6fe1 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -779,18 +779,6 @@ fhandler_tty_slave::tcflush (int) return 0; } -void -fhandler_tty_slave::send_ioctl_request (void) -{ - if (ioctl_request_event == NULL || ioctl_done_event == NULL) // slave of pty - return; - - acquire_output_mutex (INFINITE); - SetEvent (ioctl_request_event); - WaitForSingleObject (ioctl_done_event, INFINITE); - release_output_mutex (); -} - int fhandler_tty_slave::ioctl (unsigned int cmd, void *arg) { @@ -804,31 +792,51 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg) myself->pgid, get_ttyp ()->getpgid (), myself->ctty); _raise (SIGTTOU); } - get_ttyp ()->cmd = cmd; - get_ttyp ()->ioctl_retval = 0; + switch (cmd) { case TIOCGWINSZ: - get_ttyp ()->arg.winsize = get_ttyp ()->winsize; - send_ioctl_request (); - * (struct winsize *) arg = get_ttyp ()->arg.winsize; - get_ttyp ()->winsize = get_ttyp ()->arg.winsize; - break; case TIOCSWINSZ: - get_ttyp ()->ioctl_retval = -1; - get_ttyp ()->arg.winsize = * (struct winsize *) arg; - send_ioctl_request (); break; case FIONBIO: if (* (int *) arg) set_flags (get_flags () | O_NONBLOCK); else set_flags (get_flags () & ~O_NONBLOCK); - break; + goto out; default: set_errno (EINVAL); return -1; } + + acquire_output_mutex (INFINITE); + + get_ttyp ()->cmd = cmd; + get_ttyp ()->ioctl_retval = 0; + switch (cmd) + { + case TIOCGWINSZ: + get_ttyp ()->arg.winsize = get_ttyp ()->winsize; + if (ioctl_request_event) + SetEvent (ioctl_request_event); + * (struct winsize *) arg = get_ttyp ()->arg.winsize; + if (ioctl_done_event) + WaitForSingleObject (ioctl_done_event, INFINITE); + get_ttyp ()->winsize = get_ttyp ()->arg.winsize; + break; + case TIOCSWINSZ: + get_ttyp ()->ioctl_retval = -1; + get_ttyp ()->arg.winsize = * (struct winsize *) arg; + if (ioctl_request_event) + SetEvent (ioctl_request_event); + if (ioctl_done_event) + WaitForSingleObject (ioctl_done_event, INFINITE); + break; + } + + release_output_mutex (); + +out: termios_printf ("%d = ioctl (%x)", get_ttyp ()->ioctl_retval, cmd); return get_ttyp ()->ioctl_retval; } |