#if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__
/* Native Woe32 API. */
+# include <sys/ioctl.h>
# include <sys/socket.h>
# include <unistd.h>
get_nonblocking_flag (int desc)
{
HANDLE h = (HANDLE) _get_osfhandle (desc);
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return -1;
+ }
if (GetFileType (h) == FILE_TYPE_PIPE)
{
/* h is a pipe or socket. */
set_nonblocking_flag (int desc, bool value)
{
HANDLE h = (HANDLE) _get_osfhandle (desc);
+ if (h == INVALID_HANDLE_VALUE)
+ {
+ errno = EBADF;
+ return -1;
+ }
if (GetFileType (h) == FILE_TYPE_PIPE)
{
/* h is a pipe or socket. */
else
{
/* Win32 does not support non-blocking on regular files. */
+ if (!value)
+ return 0;
errno = ENOTSUP;
return -1;
}
# include <fcntl.h>
-# if !O_NONBLOCK
+# if GNULIB_defined_O_NONBLOCK
# error Please port nonblocking to your platform
# endif