[project @ 2003-10-27 12:09:44 by stolz]
authorstolz <unknown>
Mon, 27 Oct 2003 12:09:44 +0000 (12:09 +0000)
committerstolz <unknown>
Mon, 27 Oct 2003 12:09:44 +0000 (12:09 +0000)
Avoid setting O_NONBLOCK when already set.

System/Posix/Internals.hs

index 7e9e96f..5a1df90 100644 (file)
@@ -304,7 +304,9 @@ setNonBlockingFD fd = do
   -- An error when setting O_NONBLOCK isn't fatal: on some systems 
   -- there are certain file handles on which this will fail (eg. /dev/null
   -- on FreeBSD) so we throw away the return code from fcntl_write.
-  c_fcntl_write (fromIntegral fd) const_f_setfl (flags .|. o_NONBLOCK)
+  unless (testBit flags (fromIntegral o_NONBLOCK)) $ do
+    c_fcntl_write (fromIntegral fd) const_f_setfl (flags .|. o_NONBLOCK)
+    return ()
 #else
 
 -- bogus defns for win32