W3cubDocs

/Haskell 8

System.Posix.Unistd

Copyright (c) The University of Glasgow 2002
License BSD-style (see the file libraries/base/LICENSE)
Maintainer [email protected]
Stability provisional
Portability non-portable (requires POSIX)
Safe Haskell Safe
Language Haskell2010

Description

POSIX miscellaneous stuff, mostly from unistd.h

System environment

data SystemID Source

getSystemID :: IO SystemID Source

data SysVar Source

getSysVar :: SysVar -> IO Integer Source

Sleeping

sleep :: Int -> IO Int Source

Warning: 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.

usleep :: Int -> IO () Source

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.

nanosleep :: Integer -> IO () Source

Sleep for the specified duration (in nanoseconds)

GHC Note: the comment for usleep also applies here.

File synchronisation

fileSynchronise :: Fd -> IO () Source

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).

Since: unix-2.7.1.0

fileSynchroniseDataOnly :: Fd -> IO () Source

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).

Since: unix-2.7.1.0

© The University of Glasgow and others
Licensed under a BSD-style license (see top of the page).
https://downloads.haskell.org/~ghc/8.8.3/docs/html/libraries/unix-2.7.2.2/System-Posix-Unistd.html