|
System.Posix.IO | Portability | non-portable (requires POSIX) | Stability | provisional | Maintainer | libraries@haskell.org |
|
|
|
|
|
Description |
POSIX IO support
|
|
Synopsis |
|
|
|
|
Input / Output
|
|
Standard file descriptors
|
|
stdInput :: Fd |
|
stdOutput :: Fd |
|
stdError :: Fd |
|
Opening and closing files
|
|
data OpenMode |
Constructors | ReadOnly | | WriteOnly | | ReadWrite | |
|
|
|
data OpenFileFlags |
|
|
defaultFileFlags :: OpenFileFlags |
|
openFd :: FilePath -> OpenMode -> Maybe FileMode -> OpenFileFlags -> IO Fd |
|
createFile :: FilePath -> FileMode -> IO Fd |
|
closeFd :: Fd -> IO () |
|
Reading/writing data
|
|
Programmers using the fdRead and fdWrite API should be aware that
EAGAIN exceptions may occur for non-blocking IO!
|
|
fdRead :: Fd -> ByteCount -> IO (String, ByteCount) |
|
fdWrite :: Fd -> String -> IO ByteCount |
|
Seeking
|
|
fdSeek :: Fd -> SeekMode -> FileOffset -> IO FileOffset |
|
File options
|
|
data FdOption |
Constructors | AppendOnWrite | | CloseOnExec | | NonBlockingRead | | SynchronousWrites | |
|
|
|
queryFdOption :: Fd -> FdOption -> IO Bool |
|
setFdOption :: Fd -> FdOption -> Bool -> IO () |
|
Locking
|
|
type FileLock = (LockRequest, SeekMode, FileOffset, FileOffset) |
|
data LockRequest |
|
|
getLock :: Fd -> FileLock -> IO (Maybe (ProcessID, FileLock)) |
|
setLock :: Fd -> FileLock -> IO () |
|
waitToSetLock :: Fd -> FileLock -> IO () |
|
Pipes
|
|
createPipe :: IO (Fd, Fd) |
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.
|
|
Duplicating file descriptors
|
|
dup :: Fd -> IO Fd |
|
dupTo :: Fd -> Fd -> IO Fd |
|
Converting file descriptors to/from Handles
|
|
handleToFd :: Handle -> IO Fd |
Extracts the Fd from a Handle. This function has the side effect
of closing the Handle and flushing its write buffer, if necessary.
|
|
fdToHandle :: Fd -> IO Handle |
Converts an Fd into a Handle that can be used with the
standard Haskell IO library (see System.IO).
GHC only: this function has the side effect of putting the Fd
into non-blocking mode (O_NONBLOCK) due to the way the standard
IO library implements multithreaded I/O.
|
|
Produced by Haddock version 0.7 |