HORIZON HASKELLDocslts/ghc-9.10.xc74966e2026-09-27Search names, modules, packages, or :: a typeCtrl K

GHC 9.10.3 · lts/ghc-9.10.x · c74966e · 2026-09-27

Moduleunix-2.8.7.0Haskell2010

System.Posix.Unistd

POSIX miscellaneous stuff, mostly from unistd.h

  • 2 types
  • 7 values
  • Packageunix-2.8.7.0
  • Exports9
  • LanguageHaskell2010
  • LicenceBSD-3-Clause
  • SourceUnistd.hsc

System environment

4 declarations

Sleeping

3 declarations
valuesleep :: Int -> IO Int
#

This function has several shortcomings (see documentation). Please consider using Control.Concurrent.threadDelay instead.

Sleep for the specified duration (in seconds). Returns the time remaining (if the sleep was interrupted by a signal, for example).

GHC Note: threadDelay is a better choice. Since GHC uses signals for its internal clock, a call to sleep will usually be interrupted immediately. That makes sleep unusable in a program compiled with GHC, unless the RTS timer is disabled (with +RTS -V0). Furthermore, without the -threaded option, sleep will block all other user threads. Even with the -threaded option, sleep requires a full OS thread to itself. threadDelay has none of these shortcomings.

valueusleep :: Int -> IO ()
#

Sleep for the specified duration (in microseconds).

GHC Note: threadDelay is a better choice. Without the -threaded option, usleep will block all other user threads. Even with the -threaded option, usleep requires a full OS thread to itself. threadDelay has neither of these shortcomings.

valuenanosleep :: Integer -> IO ()
#

Sleep for the specified duration (in nanoseconds)

GHC Note: the comment for usleep also applies here.

File synchronisation

2 declarations
valuefileSynchronise :: Fd -> IO ()
#

Performs fsync(2) operation on file-descriptor.

Throws IOError ("unsupported operation") if platform does not provide fsync(2) (use #if HAVE_FSYNC CPP guard to detect availability).

valuefileSynchroniseDataOnly :: Fd -> IO ()
#

Performs fdatasync(2) operation on file-descriptor.

Throws IOError ("unsupported operation") if platform does not provide fdatasync(2) (use #if HAVE_FDATASYNC CPP guard to detect availability).