diff options
author | Christopher Faylor <me@cgf.cx> | 2003-09-27 03:14:07 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2003-09-27 03:14:07 +0000 |
commit | a3cbb4a7e09732e34e6a7d194f314aab6c35e4d0 (patch) | |
tree | 0daf4e7092077e955d424dba081315b2a125f0fd /winsup/cygwin/fhandler_tty.cc | |
parent | 63726a5eb47ec3a95be7dfa96443119e1c762f6b (diff) | |
download | cygnal-a3cbb4a7e09732e34e6a7d194f314aab6c35e4d0.tar.gz cygnal-a3cbb4a7e09732e34e6a7d194f314aab6c35e4d0.tar.bz2 cygnal-a3cbb4a7e09732e34e6a7d194f314aab6c35e4d0.zip |
* fhandler_tty.cc (fhandler_tty_slave::ioctl): Properly set ioctl_request event
when window size changes. Store failing errno in ioctl_retval (needed?).
Diffstat (limited to 'winsup/cygwin/fhandler_tty.cc')
-rw-r--r-- | winsup/cygwin/fhandler_tty.cc | 43 |
1 files changed, 22 insertions, 21 deletions
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 87aaca73a..e94fe4787 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -1057,34 +1057,29 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg) if (get_ttyp ()->winsize.ws_row != ((struct winsize *) arg)->ws_row || get_ttyp ()->winsize.ws_col != ((struct winsize *) arg)->ws_col) { - get_ttyp ()->arg.winsize = *(struct winsize *) arg; - if (ioctl_request_event) - { - get_ttyp ()->ioctl_retval = -1; - SetEvent (ioctl_request_event); - } + if (!ioctl_request_event) + get_ttyp ()->ioctl_retval = -EINVAL; else { + get_ttyp ()->arg.winsize = *(struct winsize *) arg; + SetEvent (ioctl_request_event); get_ttyp ()->winsize = *(struct winsize *) arg; kill (-get_ttyp ()->getpgid (), SIGWINCH); + if (ioctl_done_event) + WaitForSingleObject (ioctl_done_event, INFINITE); } - if (ioctl_done_event) - WaitForSingleObject (ioctl_done_event, INFINITE); } break; case TIOCLINUX: - int val = * (unsigned char *) arg; - if (val == 6 && ioctl_request_event && ioctl_done_event) + int val = *(unsigned char *) arg; + if (val != 6 || !ioctl_request_event || !ioctl_done_event) + get_ttyp ()->ioctl_retval = -EINVAL; + else { - get_ttyp ()->arg.value = val; + get_ttyp ()->arg.value = val; SetEvent (ioctl_request_event); WaitForSingleObject (ioctl_done_event, INFINITE); - * (unsigned char *) arg = get_ttyp ()->arg.value & 0xFF; - } - else - { - get_ttyp ()->ioctl_retval = -1; - set_errno (EINVAL); + *(unsigned char *) arg = get_ttyp ()->arg.value & 0xFF; } break; } @@ -1092,8 +1087,14 @@ fhandler_tty_slave::ioctl (unsigned int cmd, void *arg) release_output_mutex (); out: - termios_printf ("%d = ioctl (%x)", get_ttyp ()->ioctl_retval, cmd); - return get_ttyp ()->ioctl_retval; + int retval = get_ttyp ()->ioctl_retval; + if (retval < 0) + { + set_errno (-retval); + retval = -1; + } + termios_printf ("%d = ioctl (%x)", retval, cmd); + return retval; } /******************************************************* @@ -1250,7 +1251,7 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg) switch (cmd) { case TIOCPKT: - pktmode = * (int *) arg; + pktmode = *(int *) arg; break; case TIOCGWINSZ: *(struct winsize *) arg = get_ttyp ()->winsize; @@ -1259,7 +1260,7 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg) if (get_ttyp ()->winsize.ws_row != ((struct winsize *) arg)->ws_row || get_ttyp ()->winsize.ws_col != ((struct winsize *) arg)->ws_col) { - get_ttyp ()->winsize = * (struct winsize *) arg; + get_ttyp ()->winsize = *(struct winsize *) arg; kill (-get_ttyp ()->getpgid (), SIGWINCH); } break; |