* 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

@ -1,3 +1,8 @@
2002-11-06 Sergey Okhapkin <sos@prospect.com.ru>
* fhandler.h (class fhandler_pipe): New ioctl() method.
* pipe.cc (fhandler_pipe::ioctl): New.
2002-11-07 Christopher Faylor <cgf@redhat.com>
* fhandler_serial.cc (fhandler_serial::ioctl): Fix typo.

View File

@ -459,6 +459,7 @@ class fhandler_pipe: public fhandler_base
int close ();
void create_guard (SECURITY_ATTRIBUTES *sa) {guard = CreateMutex (sa, FALSE, NULL);}
int dup (fhandler_base *child);
int ioctl (unsigned int cmd, void *);
void fixup_after_fork (HANDLE);
bool hit_eof ();
void set_eof () {broken_pipe = true;}

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