[project @ 2001-09-26 10:35:41 by simonmar]
authorsimonmar <unknown>
Wed, 26 Sep 2001 10:35:41 +0000 (10:35 +0000)
committersimonmar <unknown>
Wed, 26 Sep 2001 10:35:41 +0000 (10:35 +0000)
A failure while trying to set O_NONBLOCK on a file descriptor should
be a non-fatal error.  It turns out that on FreeBSD it is an error
(ENODEV) to try to set O_NONBLOCK on /dev/null.

MERGE TO STABLE

ghc/lib/std/PrelPosix.hsc

index a2dfdd6..c6b09f5 100644 (file)
@@ -1,7 +1,7 @@
 {-# OPTIONS -fno-implicit-prelude #-}
 
 -- ---------------------------------------------------------------------------
--- $Id: PrelPosix.hsc,v 1.13 2001/08/23 10:36:50 sewardj Exp $
+-- $Id: PrelPosix.hsc,v 1.14 2001/09/26 10:35:41 simonmar Exp $
 --
 -- POSIX support layer for the standard libraries
 --
@@ -212,9 +212,11 @@ getEcho fd = return False
 setNonBlockingFD fd = do
   flags <- throwErrnoIfMinus1Retry "setNonBlockingFD"
                 (fcntl_read (fromIntegral fd) (#const F_GETFL))
-  throwErrnoIfMinus1Retry "setNonBlockingFD"
-       (fcntl_write (fromIntegral fd) 
-          (#const F_SETFL) (flags .|. #const O_NONBLOCK))
+  -- 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.
+  fcntl_write (fromIntegral fd) 
+       (#const F_SETFL) (flags .|. #const O_NONBLOCK)
 #else
 
 -- bogus defns for win32