diff options
author | Christopher Faylor <me@cgf.cx> | 2002-11-09 03:17:40 +0000 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-11-09 03:17:40 +0000 |
commit | 49f7ea16756dd7f341edeecd2dee45083ab38945 (patch) | |
tree | 3d3116eba6dca08f137092f6e7d59ca200757ca4 /winsup/cygwin/pipe.cc | |
parent | 7c4f9b9a05214fcfb692147a1883e52d2d2de1df (diff) | |
download | cygnal-49f7ea16756dd7f341edeecd2dee45083ab38945.tar.gz cygnal-49f7ea16756dd7f341edeecd2dee45083ab38945.tar.bz2 cygnal-49f7ea16756dd7f341edeecd2dee45083ab38945.zip |
* fhandler.h (class fhandler_pipe): New ioctl() method.
* pipe.cc (fhandler_pipe::ioctl): New.
Diffstat (limited to 'winsup/cygwin/pipe.cc')
-rw-r--r-- | winsup/cygwin/pipe.cc | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc index b37a7751e..fe712e25e 100644 --- a/winsup/cygwin/pipe.cc +++ b/winsup/cygwin/pipe.cc @@ -13,6 +13,7 @@ details. */ #include "winsup.h" #include <unistd.h> #include <errno.h> +#include <sys/socket.h> #include "cygerrno.h" #include "security.h" #include "fhandler.h" @@ -179,6 +180,33 @@ make_pipe (int fildes[2], unsigned int psize, int mode) return res; } +int +fhandler_pipe::ioctl (unsigned int cmd, void *p) +{ + int n; + + switch (cmd) + { + case FIONREAD: + if (get_device () == FH_PIPEW) + { + set_errno (EINVAL); + return -1; + } + if (!PeekNamedPipe (get_handle (), NULL, 0, NULL, (DWORD *) &n, NULL)) + { + __seterrno (); + return -1; + } + break; + default: + return fhandler_base::ioctl (cmd, p); + break; + } + *(int *) p = n; + return 0; +} + extern "C" int pipe (int filedes[2]) { |