-#ifndef WIN32
- fcntl (sigpipe [0], F_SETFD, FD_CLOEXEC);
- fcntl (sigpipe [1], F_SETFD, FD_CLOEXEC);
-
- /* rather than sort out wether we really need nb, set it */
- fcntl (sigpipe [0], F_SETFL, O_NONBLOCK);
- fcntl (sigpipe [1], F_SETFL, O_NONBLOCK);
+#ifdef _WIN32
+ int arg = 1;
+ ioctlsocket (_get_osfhandle (fd), FIONBIO, &arg);
+#else
+ fcntl (fd, F_SETFD, FD_CLOEXEC);
+ fcntl (fd, F_SETFL, O_NONBLOCK);