aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin/pipe.cc
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin/pipe.cc')
-rw-r--r--winsup/cygwin/pipe.cc28
1 files changed, 28 insertions, 0 deletions
diff --git a/winsup/cygwin/pipe.cc b/winsup/cygwin/pipe.cc
index b37a775..fe712e2 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])
{