diff options
author | stolz <unknown> | 2003-02-27 15:46:57 +0000 |
---|---|---|
committer | stolz <unknown> | 2003-02-27 15:46:57 +0000 |
commit | f48e575611b5ba4be82b0f904a1642c0cad628b7 (patch) | |
tree | e4806510155105eb830ea44812a6172920614fb2 /System/Posix/IO.hsc | |
parent | 696266aceb54ce4ad5aa728824a267999cc9a464 (diff) |
[project @ 2003-02-27 15:46:57 by stolz]
- Add documentation for fd{Read,Write} & createPipe
- Unbreak setFdOption which didn't set any options at all
Diffstat (limited to 'System/Posix/IO.hsc')
-rw-r--r-- | System/Posix/IO.hsc | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/System/Posix/IO.hsc b/System/Posix/IO.hsc index f8d5bb1..86f8461 100644 --- a/System/Posix/IO.hsc +++ b/System/Posix/IO.hsc @@ -25,7 +25,10 @@ module System.Posix.IO ( openFd, createFile, closeFd, - -- ** Reading/writing data + -- ** Reading\/writing data + -- |Programmers using the 'fdRead' and 'fdWrite' API should be aware that + -- EAGAIN exceptions may occur for non-blocking IO! + fdRead, fdWrite, -- ** Seeking @@ -71,6 +74,10 @@ import qualified GHC.Handle -- ----------------------------------------------------------------------------- -- Pipes +-- |The 'createPipe' function creates a pair of connected file descriptors. The first +-- component is the fd to read from, the second is the write end. +-- Although pipes may be bidirectional, this behaviour is not portable and +-- programmers should use two separate pipes for this purpose. createPipe :: IO (Fd, Fd) createPipe = @@ -218,14 +225,14 @@ foreign import ccall unsafe "fcntl" setFdOption :: Fd -> FdOption -> Bool -> IO () setFdOption fd opt val = do - r <- throwErrnoIfMinus1 "setFdOption" (c_fcntl_read fd flag) + r <- throwErrnoIfMinus1 "setFdOption" (c_fcntl_read fd getflag) let r' | val = r .|. opt_val | otherwise = r .&. (complement opt_val) - throwErrnoIfMinus1_ "setFdOption" (c_fcntl_write fd flag r') + throwErrnoIfMinus1_ "setFdOption" (c_fcntl_write fd setflag r') where - flag = case opt of - CloseOnExec -> (#const F_GETFD) - other -> (#const F_GETFL) + (getflag,setflag)= case opt of + CloseOnExec -> ((#const F_GETFD),(#const F_SETFD)) + other -> ((#const F_GETFL),(#const F_SETFL)) opt_val = case opt of CloseOnExec -> (#const FD_CLOEXEC) AppendOnWrite -> (#const O_APPEND) |