* fhandler_tty.cc (fhandler_pty_slave::ioctl): Drop FIONBIO case.

Handle FIONREAD.
	(fhandler_pty_master::ioctl): Ditto.  Call fhandler_base::ioctl to
	decode default condition.
	* fhandler_console.cc (fhandler_console::ioctl): Handle FIONREAD.
This commit is contained in:
Corinna Vinschen 2011-07-22 18:50:42 +00:00
parent da7287ed5d
commit cfb517f39a
3 changed files with 50 additions and 13 deletions

@ -1,3 +1,11 @@
2011-07-22 Corinna Vinschen <corinna@vinschen.de>
* fhandler_tty.cc (fhandler_pty_slave::ioctl): Drop FIONBIO case.
Handle FIONREAD.
(fhandler_pty_master::ioctl): Ditto. Call fhandler_base::ioctl to
decode default condition.
* fhandler_console.cc (fhandler_console::ioctl): Handle FIONREAD.
2011-07-21 Christopher Faylor <me.cygwin2011@cgf.cx> 2011-07-21 Christopher Faylor <me.cygwin2011@cgf.cx>
Corinna Vinschen <corinna@vinschen.de> Corinna Vinschen <corinna@vinschen.de>

@ -32,6 +32,7 @@ details. */
#include "cygtls.h" #include "cygtls.h"
#include "tls_pbuf.h" #include "tls_pbuf.h"
#include "registry.h" #include "registry.h"
#include <asm/socket.h>
/* Don't make this bigger than NT_MAX_PATH as long as the temporary buffer /* Don't make this bigger than NT_MAX_PATH as long as the temporary buffer
is allocated using tmp_pathbuf!!! */ is allocated using tmp_pathbuf!!! */
@ -887,11 +888,20 @@ fhandler_console::ioctl (unsigned int cmd, void *buf)
*(unsigned char *) buf = (unsigned char) dev_state.nModifiers; *(unsigned char *) buf = (unsigned char) dev_state.nModifiers;
return 0; return 0;
} }
else set_errno (EINVAL);
{ return -1;
set_errno (EINVAL); case FIONREAD:
return -1; {
} DWORD n;
if (!GetNumberOfConsoleInputEvents (get_io_handle (), &n))
{
__seterrno ();
return -1;
}
*(int *) buf = (int) n;
return 0;
}
break;
} }
return fhandler_base::ioctl (cmd, buf); return fhandler_base::ioctl (cmd, buf);

@ -24,6 +24,7 @@ details. */
#include "shared_info.h" #include "shared_info.h"
#include "cygthread.h" #include "cygthread.h"
#include "child_info.h" #include "child_info.h"
#include <asm/socket.h>
#define close_maybe(h) \ #define close_maybe(h) \
do { \ do { \
@ -960,10 +961,6 @@ fhandler_pty_slave::ioctl (unsigned int cmd, void *arg)
case TIOCGWINSZ: case TIOCGWINSZ:
case TIOCSWINSZ: case TIOCSWINSZ:
break; break;
case FIONBIO:
set_nonblocking (*(int *) arg);
retval = 0;
goto out;
case TIOCGPGRP: case TIOCGPGRP:
{ {
pid_t pid = this->tcgetpgrp (); pid_t pid = this->tcgetpgrp ();
@ -979,6 +976,21 @@ fhandler_pty_slave::ioctl (unsigned int cmd, void *arg)
case TIOCSPGRP: case TIOCSPGRP:
retval = this->tcsetpgrp ((pid_t) arg); retval = this->tcsetpgrp ((pid_t) arg);
goto out; goto out;
case FIONREAD:
{
int n;
if (!PeekNamedPipe (get_handle (), NULL, 0, NULL, (DWORD *) &n, NULL))
{
__seterrno ();
retval = -1;
}
else
{
*(int *) arg = n;
retval = 0;
}
}
goto out;
default: default:
return fhandler_base::ioctl (cmd, arg); return fhandler_base::ioctl (cmd, arg);
} }
@ -1364,12 +1376,19 @@ fhandler_pty_master::ioctl (unsigned int cmd, void *arg)
break; break;
case TIOCSPGRP: case TIOCSPGRP:
return this->tcsetpgrp ((pid_t) arg); return this->tcsetpgrp ((pid_t) arg);
case FIONBIO: case FIONREAD:
set_nonblocking (*(int *) arg); {
int n;
if (!PeekNamedPipe (to_master, NULL, 0, NULL, (DWORD *) &n, NULL))
{
__seterrno ();
return -1;
}
*(int *) arg = n;
}
break; break;
default: default:
set_errno (EINVAL); return fhandler_base::ioctl (cmd, arg);
return -1;
} }
return 0; return 0;
} }