diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2001-08-14 07:41:45 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2001-08-14 07:41:45 +0000 |
commit | 6a574f1ad6df42447a242b521c3bdc9e9039910c (patch) | |
tree | ae49f1fb41c40a10c1ab7e97240d0eb3b89fb265 /winsup/cygwin/fhandler_tty.cc | |
parent | 52c80be81471afa563671b5b78e8de702faa54d6 (diff) | |
download | newlib-6a574f1ad6df42447a242b521c3bdc9e9039910c.zip newlib-6a574f1ad6df42447a242b521c3bdc9e9039910c.tar.gz newlib-6a574f1ad6df42447a242b521c3bdc9e9039910c.tar.bz2 |
* fhandler.cc (fhandler_base::fcntl): Use new O_NONBLOCK_MASK define.
* fhandler.h: Move definitions of O_NOSYMLINK, O_DIROPEN and
OLD_O_NDELAY from winsup.h to here. Add O_NONBLOCK_MASK define.
* fhandler_socket.cc (fhandler_socket::close): Add hack to allow
a graceful shutdown even if shutdown() hasn't been called by the
application. Add debug output.
(fhandler_socket::ioctl): Set fhandler's NONBLOCK flag according
to FIONBIO setting.
(fhandler_socket::fcntl): Use new O_NONBLOCK_MASK define. Actually
set `request' before using it.
* fhandler_tty.cc: Use new O_NONBLOCK_MASK define throughout.
(fhandler_tty_slave::ioctl): Set fhandler's NONBLOCK flag according
to FIONBIO setting.
(fhandler_pty_master::ioctl): Ditto.
* net.cc (wsock_event::prepare): Compare WSACreateEvent return code
with `WSA_INVALID_EVENT' according to MSDN.
* syscalls.cc (_read): Use new O_NONBLOCK_MASK define.
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 7edc364..942f31d 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -25,6 +25,8 @@ details. */ #include "pinfo.h" #include "cygheap.h" #include "shared_info.h" +#include "cygwin/version.h" +#include "perprocess.h" /* Tty master stuff */ @@ -295,7 +297,7 @@ fhandler_pty_master::process_slave_output (char *buf, size_t len, int pktmode_on break; if (hit_eof ()) goto out; - if (n == 0 && (get_flags () & (O_NONBLOCK | O_NDELAY)) != 0) + if (n == 0 && (get_flags () & O_NONBLOCK_MASK) != 0) { set_errno (EAGAIN); rc = -1; @@ -747,7 +749,7 @@ fhandler_tty_slave::read (void *ptr, size_t len) break; } if (get_ttyp ()->ti.c_lflag & ICANON || - get_flags () & (O_NONBLOCK | O_NDELAY)) + get_flags () & O_NONBLOCK_MASK) break; if (totalread >= vmin && (vmin > 0 || totalread > 0)) break; @@ -913,10 +915,11 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg) case TIOCSWINSZ: break; case FIONBIO: - if (* (int *) arg) - set_flags (get_flags () | O_NONBLOCK); - else - set_flags (get_flags () & ~O_NONBLOCK); + { + int current = get_flags () & O_NONBLOCK_MASK; + int new_flags = *(int *) arg ? (!current ? O_NONBLOCK : current) : 0; + set_flags ((get_flags () & ~O_NONBLOCK_MASK) | new_flags); + } goto out; default: set_errno (EINVAL); @@ -1096,10 +1099,11 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg) _kill (-get_ttyp ()->getpgid (), SIGWINCH); break; case FIONBIO: - if (* (int *) arg) - set_flags (get_flags () | O_NONBLOCK); - else - set_flags (get_flags () & ~O_NONBLOCK); + { + int current = get_flags () & O_NONBLOCK_MASK; + int new_flags = *(int *) arg ? (!current ? O_NONBLOCK : current) : 0; + set_flags ((get_flags () & ~O_NONBLOCK_MASK) | new_flags); + } break; default: set_errno (EINVAL); |