# HG changeset patch # User Bruno Haible # Date 1328369970 -3600 # Node ID 84b5f6cfae4baffc42852d103fbc1df115268e2c # Parent f34ee844ca92b492422c88870238aa4ba87d5f02 ioctl: Fix test failure on native Windows. * lib/ioctl.c: Include msvc-nothrow.h. (primary_ioctl): If fd is not a valid handle, set errno to EBADF. diff -r f34ee844ca92 -r 84b5f6cfae4b ChangeLog --- a/ChangeLog Sat Feb 04 14:59:43 2012 +0100 +++ b/ChangeLog Sat Feb 04 16:39:30 2012 +0100 @@ -1,3 +1,9 @@ +2012-02-04 Bruno Haible + + ioctl: Fix test failure on native Windows. + * lib/ioctl.c: Include msvc-nothrow.h. + (primary_ioctl): If fd is not a valid handle, set errno to EBADF. + 2012-02-04 Bruno Haible fsync: Avoid test failure on native Windows. diff -r f34ee844ca92 -r 84b5f6cfae4b lib/ioctl.c --- a/lib/ioctl.c Sat Feb 04 14:59:43 2012 +0100 +++ b/lib/ioctl.c Sat Feb 04 16:39:30 2012 +0100 @@ -47,6 +47,8 @@ # include # include "fd-hook.h" +/* Get _get_osfhandle. */ +# include "msvc-nothrow.h" static int primary_ioctl (int fd, int request, void *arg) @@ -55,7 +57,10 @@ fds non-blocking, use the gnulib 'nonblocking' module, until gnulib implements fcntl F_GETFL / F_SETFL with O_NONBLOCK. */ - errno = ENOSYS; + if ((HANDLE) _get_osfhandle (fd) != INVALID_HANDLE_VALUE) + errno = ENOSYS; + else + errno = EBADF; return -1; }