| Safe Haskell | Safe |
|---|---|
| Language | Haskell2010 |
System.IO.OS
Description
This module bridges between Haskell handles and underlying operating-system features.
Synopsis
- withFileDescriptorReadingBiased :: Handle -> (CInt -> IO r) -> IO r
- withFileDescriptorWritingBiased :: Handle -> (CInt -> IO r) -> IO r
- withWindowsHandleReadingBiased :: Handle -> (Ptr () -> IO r) -> IO r
- withWindowsHandleWritingBiased :: Handle -> (Ptr () -> IO r) -> IO r
- withFileDescriptorReadingBiasedRaw :: Handle -> (CInt -> IO r) -> IO r
- withFileDescriptorWritingBiasedRaw :: Handle -> (CInt -> IO r) -> IO r
- withWindowsHandleReadingBiasedRaw :: Handle -> (Ptr () -> IO r) -> IO r
- withWindowsHandleWritingBiasedRaw :: Handle -> (Ptr () -> IO r) -> IO r
Obtaining file descriptors and Windows handles
withFileDescriptorReadingBiased :: Handle -> (CInt -> IO r) -> IO r Source #
Executes a user-provided action on the POSIX file descriptor that underlies a handle or specifically on the POSIX file descriptor for reading if the handle uses different file descriptors for reading and writing. The Haskell-managed buffers related to the file descriptor are flushed before the user-provided action is run. While this action is executed, further operations on the handle are blocked to a degree that interference with this action is prevented.
If the handle does not use POSIX file descriptors, an exception is thrown.
See below for caveats regarding this operation.
withFileDescriptorWritingBiased :: Handle -> (CInt -> IO r) -> IO r Source #
Executes a user-provided action on the POSIX file descriptor that underlies a handle or specifically on the POSIX file descriptor for writing if the handle uses different file descriptors for reading and writing. The Haskell-managed buffers related to the file descriptor are flushed before the user-provided action is run. While this action is executed, further operations on the handle are blocked to a degree that interference with this action is prevented.
If the handle does not use POSIX file descriptors, an exception is thrown.
See below for caveats regarding this operation.
withWindowsHandleReadingBiased :: Handle -> (Ptr () -> IO r) -> IO r Source #
Executes a user-provided action on the Windows handle that underlies a Haskell handle or specifically on the Windows handle for reading if the Haskell handle uses different Windows handles for reading and writing. The Haskell-managed buffers related to the Windows handle are flushed before the user-provided action is run. While this action is executed, further operations on the Haskell handle are blocked to a degree that interference with this action is prevented.
If the Haskell handle does not use Windows handles, an exception is thrown.
See below for caveats regarding this operation.
withWindowsHandleWritingBiased :: Handle -> (Ptr () -> IO r) -> IO r Source #
Executes a user-provided action on the Windows handle that underlies a Haskell handle or specifically on the Windows handle for writing if the Haskell handle uses different Windows handles for reading and writing. The Haskell-managed buffers related to the Windows handle are flushed before the user-provided action is run. While this action is executed, further operations on the Haskell handle are blocked to a degree that interference with this action is prevented.
If the Haskell handle does not use Windows handles, an exception is thrown.
See below for caveats regarding this operation.
withFileDescriptorReadingBiasedRaw :: Handle -> (CInt -> IO r) -> IO r Source #
Like withFileDescriptorReadingBiased except that Haskell-managed buffers
are not flushed.
withFileDescriptorWritingBiasedRaw :: Handle -> (CInt -> IO r) -> IO r Source #
Like withFileDescriptorWritingBiased except that Haskell-managed buffers
are not flushed.
withWindowsHandleReadingBiasedRaw :: Handle -> (Ptr () -> IO r) -> IO r Source #
Like withWindowsHandleReadingBiased except that Haskell-managed buffers
are not flushed.
withWindowsHandleWritingBiasedRaw :: Handle -> (Ptr () -> IO r) -> IO r Source #
Like withWindowsHandleWritingBiased except that Haskell-managed buffers
are not flushed.
Caveats
There are the following caveats regarding the above operations:
- Flushing of buffers can fail if the given handle is readable but not seekable.
If one of these operations is performed as part of an action executed by
unsafePerformIO,unsafeInterleaveIO, or one of their “dupable” variants and the user-provided action receives an asychnchronous exception and does not catch it, then the following happens:- Before the overall computation is suspended, the blocking of handle operations is removed.
- When the computation is later resumed due to another evaluation attempt, the blocking of handle operations is reinstantiated, the Haskell-managed buffers are flushed again, and the user-provided action is run from the beginning.
Repeating the previously executed part of the user-provided action
cannot be avoided apparently. See the [async] note in the source code
of GHC.Internal.IO.Handle.Internals for further explanation.