createPipe :: IO (Fd, Fd)
createPipe
calls pipe
to create a pipe and returns a pair of
Fd
s, the first for reading and the second for writing.
dup :: Fd -> IO Fd
dup fd
calls dup
to duplicate Fd
fd
to
another Fd
.
dupTo :: Fd -> Fd -> IO ()
dupTo src dst
calls dup2
to duplicate Fd
src
to Fd
dst
.
fdClose :: Fd -> IO ()
fdClose fd
calls close
to close Fd
fd
.
fdRead :: Fd -> ByteCount -> IO (String, ByteCount)
fdRead fd nbytes
calls read
to read at most nbytes
bytes from Fd
fd
, and returns the result as a string
paired with the number of bytes actually read.
The operation may fail with:
EOF
End of file has been reached.
SystemError
Various other causes.
fdWrite :: Fd -> String -> IO ByteCount
fdWrite fd s
calls write
to write
the string s
to Fd
fd
as a
contiguous sequence of bytes. It returns the number of bytes successfully
written.
queryFdOption :: FdOption -> Fd -> IO Bool
getFdOption opt fd
calls fcntl
to determine whether or
not the flag associated with FdOption
opt
is set for
Fd
fd
.
setFdOption :: Fd -> FdOption -> Bool -> IO ()
setFdOption fd opt val
calls fcntl
to set the flag
associated with FdOption
opt
on Fd
fd
to
val
.
getLock :: Fd -> FileLock -> IO (Maybe (ProcessID, FileLock))
getLock fd lock
calls fcntl
to get the first FileLock
for Fd
fd
which blocks the FileLock
lock
. If
no such FileLock
exists, getLock
returns Nothing
.
Otherwise, it returns Just (pid, block)
, where block
is the
blocking FileLock
and pid
is the ProcessID
of the
process holding the blocking FileLock
.
setLock :: Fd -> FileLock -> IO ()
setLock fd lock
calls fcntl
with F_SETLK
to set or
clear a lock segment for Fd
fd
as indicated by the
FileLock
lock
. setLock
does not block, but fails with
SystemError
if the request cannot be satisfied immediately.
waitToSetLock :: Fd -> FileLock -> IO ()
waitToSetLock fd lock
calls fcntl
with F_SETLKW
to set
or clear a lock segment for Fd
fd
as indicated by the
FileLock
lock
. If the request cannot be satisfied
immediately, waitToSetLock
blocks until the request can be
satisfied.
fdSeek :: Fd -> SeekMode -> FileOffset -> IO FileOffset
fdSeek fd whence offset
calls lseek
to position the
Fd
fd
at the given offset
from the starting location
indicated by whence
. It returns the resulting offset from the
start of the file in bytes.