unix-2.6.0.1: POSIX functionality

Portability | non-portable (requires POSIX)
Stability | provisional
Maintainer | libraries@haskell.org
Safe Haskell | Trustworthy

System.Posix.Unistd

Contents

- System environment
- Sleeping

Description

POSIX miscellaneous stuff, mostly from unistd.h

Synopsis

- data SystemID = SystemID {
  - systemName :: String
  - nodeName :: String
  - release :: String
  - version :: String
  - machine :: String
  }
- getSystemID :: IO SystemID
- data SysVar
  - = ArgumentLimit
  - | ChildLimit
  - | ClockTick
  - | GroupLimit
  - | OpenFileLimit
  - | PosixVersion
  - | HasSavedIDs
  - | HasJobControl
- getSysVar :: SysVar -> IO Integer
- sleep :: Int -> IO Int
- usleep :: Int -> IO ()
- nanosleep :: Integer -> IO ()

# System environment

data SystemID

Constructors

SystemID |
Fields systemName :: String nodeName :: String release :: String version :: String machine :: String

getSystemID :: IO SystemID

data SysVar

Constructors

ArgumentLimit |
ChildLimit |
ClockTick |
GroupLimit |
OpenFileLimit |
PosixVersion |
HasSavedIDs |
HasJobControl |

getSysVar :: SysVar -> IO Integer

# Sleeping

sleep :: Int -> IO Int

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

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

Sleep for the specified duration (in nanoseconds)

GHC Note: the comment for `usleep` also applies here.