* fhandler.h (class fhandler_pipe): New ioctl() method.

* pipe.cc (fhandler_pipe::ioctl): New.
This commit is contained in:
Christopher Faylor
2002-11-09 03:17:40 +00:00
parent 7c4f9b9a05
commit 49f7ea1675
3 changed files with 34 additions and 0 deletions

View File

@@ -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])
{