-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | POSIX functionality
--   
--   This package gives you access to the set of operating system services
--   standardised by POSIX 1003.1b (or the IEEE Portable Operating System
--   Interface for Computing Environments - IEEE Std. 1003.1).
--   
--   The package is not supported under Windows (except under Cygwin).
@package unix
@version 2.4.2.0

module System.Posix.Process.Internals
pPrPr_disableITimers :: IO ()
c_execvpe :: CString -> Ptr CString -> Ptr CString -> IO CInt
decipherWaitStatus :: CInt -> IO ProcessStatus
data ProcessStatus
Exited :: ExitCode -> ProcessStatus
Terminated :: Signal -> ProcessStatus
Stopped :: Signal -> ProcessStatus
instance Eq ProcessStatus
instance Ord ProcessStatus
instance Show ProcessStatus


-- | POSIX error support
module System.Posix.Error

-- | as <a>throwErrno</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPath :: String -> FilePath -> IO a

-- | as <a>throwErrnoIf</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPathIf :: (a -> Bool) -> String -> FilePath -> IO a -> IO a

-- | as <a>throwErrnoIf_</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPathIf_ :: (a -> Bool) -> String -> FilePath -> IO a -> IO ()
throwErrnoPathIfRetry :: (a -> Bool) -> String -> FilePath -> IO a -> IO a

-- | as <a>throwErrnoIfNull</a>, but exceptions include the given path when
--   appropriate.
throwErrnoPathIfNull :: String -> FilePath -> IO (Ptr a) -> IO (Ptr a)
throwErrnoPathIfNullRetry :: String -> FilePath -> IO (Ptr a) -> IO (Ptr a)

-- | as <a>throwErrnoIfMinus1</a>, but exceptions include the given path
--   when appropriate.
throwErrnoPathIfMinus1 :: Num a => String -> FilePath -> IO a -> IO a

-- | as <a>throwErrnoIfMinus1_</a>, but exceptions include the given path
--   when appropriate.
throwErrnoPathIfMinus1_ :: Num a => String -> FilePath -> IO a -> IO ()
throwErrnoPathIfMinus1Retry :: Num a => String -> FilePath -> IO a -> IO a


-- | DLOpen and friend Derived from GModule.chs by M.Weber &amp;
--   M.Chakravarty which is part of c2hs I left the API more or less the
--   same, mostly the flags are different.
module System.Posix.DynamicLinker.Prim
c_dlopen :: CString -> CInt -> IO (Ptr ())
c_dlsym :: Ptr () -> CString -> IO (FunPtr a)
c_dlerror :: IO CString
c_dlclose :: (Ptr ()) -> IO CInt
haveRtldNext :: Bool
haveRtldLocal :: Bool
packRTLDFlags :: [RTLDFlags] -> CInt
data RTLDFlags
RTLD_LAZY :: RTLDFlags
RTLD_NOW :: RTLDFlags
RTLD_GLOBAL :: RTLDFlags
RTLD_LOCAL :: RTLDFlags
packDL :: DL -> Ptr ()

-- | Flags for <tt>System.Posix.DynamicLinker.dlsym</tt>. Notice that
--   <a>Next</a> might not be available on your particular platform!
data DL
Null :: DL
Next :: DL
Default :: DL
DLHandle :: (Ptr ()) -> DL
instance Show RTLDFlags
instance Read RTLDFlags
instance Show DL


-- | Dynamic linker support through dlopen()
module System.Posix.DynamicLinker
dlopen :: String -> [RTLDFlags] -> IO DL

-- | <a>dlsym</a> returns the address binding of the symbol described in
--   <tt>symbol</tt>, as it occurs in the shared object identified by
--   <tt>source</tt>.
dlsym :: DL -> String -> IO (FunPtr a)
dlerror :: IO String
dlclose :: DL -> IO ()
withDL :: String -> [RTLDFlags] -> (DL -> IO a) -> IO a
withDL_ :: String -> [RTLDFlags] -> (DL -> IO a) -> IO ()

-- | <a>undl</a> obtains the raw handle. You mustn't do something like
--   <tt>withDL mod flags $ liftM undl &gt;&gt;= p -&gt; use p</tt>
undl :: DL -> Ptr ()


-- | DLOpen support, old API Derived from GModule.chs by M.Weber &amp;
--   M.Chakravarty which is part of c2hs I left the API more or less the
--   same, mostly the flags are different.
module System.Posix.DynamicLinker.Module
data Module
moduleOpen :: String -> [RTLDFlags] -> IO Module
moduleSymbol :: Module -> String -> IO (FunPtr a)
moduleClose :: Module -> IO ()
moduleError :: IO String
withModule :: Maybe String -> String -> [RTLDFlags] -> (Module -> IO a) -> IO a
withModule_ :: Maybe String -> String -> [RTLDFlags] -> (Module -> IO a) -> IO ()


-- | POSIX shared memory support.
module System.Posix.SharedMem
data ShmOpenFlags
ShmOpenFlags :: Bool -> Bool -> Bool -> Bool -> ShmOpenFlags

-- | If true, open the shm object read-write rather than read-only.
shmReadWrite :: ShmOpenFlags -> Bool

-- | If true, create the shm object if it does not exist.
shmCreate :: ShmOpenFlags -> Bool

-- | If true, throw an exception if the shm object already exists.
shmExclusive :: ShmOpenFlags -> Bool

-- | If true, wipe the contents of the shm object after opening it.
shmTrunc :: ShmOpenFlags -> Bool

-- | Open a shared memory object with the given name, flags, and mode.
shmOpen :: String -> ShmOpenFlags -> FileMode -> IO Fd

-- | Delete the shared memory object with the given name.
shmUnlink :: String -> IO ()


-- | POSIX named semaphore support.
module System.Posix.Semaphore
data OpenSemFlags
OpenSemFlags :: Bool -> Bool -> OpenSemFlags

-- | If true, create the semaphore if it does not yet exist.
semCreate :: OpenSemFlags -> Bool

-- | If true, throw an exception if the semaphore already exists.
semExclusive :: OpenSemFlags -> Bool
data Semaphore

-- | Open a named semaphore with the given name, flags, mode, and initial
--   value.
semOpen :: String -> OpenSemFlags -> FileMode -> Int -> IO Semaphore

-- | Delete the semaphore with the given name.
semUnlink :: String -> IO ()

-- | Lock the semaphore, blocking until it becomes available. Since this is
--   done through a system call, this will block the *entire runtime*, not
--   just the current thread. If this is not the behaviour you want, use
--   semThreadWait instead.
semWait :: Semaphore -> IO ()

-- | Attempt to lock the semaphore without blocking. Immediately return
--   False if it is not available.
semTryWait :: Semaphore -> IO Bool

-- | Poll the semaphore until it is available, then lock it. Unlike
--   semWait, this will block only the current thread rather than the
--   entire process.
semThreadWait :: Semaphore -> IO ()

-- | Unlock the semaphore.
semPost :: Semaphore -> IO ()

-- | Return the semaphore's current value.
semGetValue :: Semaphore -> IO Int


-- | POSIX resource support
module System.Posix.Resource
data ResourceLimit
ResourceLimitInfinity :: ResourceLimit
ResourceLimitUnknown :: ResourceLimit
ResourceLimit :: Integer -> ResourceLimit
data ResourceLimits
ResourceLimits :: ResourceLimit -> ResourceLimit -> ResourceLimits
softLimit :: ResourceLimits -> ResourceLimit
hardLimit :: ResourceLimits -> ResourceLimit
data Resource
ResourceCoreFileSize :: Resource
ResourceCPUTime :: Resource
ResourceDataSize :: Resource
ResourceFileSize :: Resource
ResourceOpenFiles :: Resource
ResourceStackSize :: Resource
getResourceLimit :: Resource -> IO ResourceLimits
setResourceLimit :: Resource -> ResourceLimits -> IO ()
instance Eq Resource
instance Eq ResourceLimit
instance Eq ResourceLimits


-- | POSIX user/group support
module System.Posix.User

-- | <tt>getRealUserID</tt> calls <tt>getuid</tt> to obtain the real
--   <tt>UserID</tt> associated with the current process.
getRealUserID :: IO UserID

-- | <tt>getRealGroupID</tt> calls <tt>getgid</tt> to obtain the real
--   <tt>GroupID</tt> associated with the current process.
getRealGroupID :: IO GroupID

-- | <tt>getEffectiveUserID</tt> calls <tt>geteuid</tt> to obtain the
--   effective <tt>UserID</tt> associated with the current process.
getEffectiveUserID :: IO UserID

-- | <tt>getEffectiveGroupID</tt> calls <tt>getegid</tt> to obtain the
--   effective <tt>GroupID</tt> associated with the current process.
getEffectiveGroupID :: IO GroupID

-- | <tt>getGroups</tt> calls <tt>getgroups</tt> to obtain the list of
--   supplementary <tt>GroupID</tt>s associated with the current process.
getGroups :: IO [GroupID]

-- | <tt>getLoginName</tt> calls <tt>getlogin</tt> to obtain the login name
--   associated with the current process.
getLoginName :: IO String

-- | <tt>getEffectiveUserName</tt> gets the name associated with the
--   effective <tt>UserID</tt> of the process.
getEffectiveUserName :: IO String
data GroupEntry
GroupEntry :: String -> String -> GroupID -> [String] -> GroupEntry

-- | The name of this group (gr_name)
groupName :: GroupEntry -> String

-- | The password for this group (gr_passwd)
groupPassword :: GroupEntry -> String

-- | The unique numeric ID for this group (gr_gid)
groupID :: GroupEntry -> GroupID

-- | A list of zero or more usernames that are members (gr_mem)
groupMembers :: GroupEntry -> [String]

-- | <tt>getGroupEntryForID gid</tt> calls <tt>getgrgid</tt> to obtain the
--   <tt>GroupEntry</tt> information associated with <tt>GroupID</tt>
--   <tt>gid</tt>.
getGroupEntryForID :: GroupID -> IO GroupEntry

-- | <tt>getGroupEntryForName name</tt> calls <tt>getgrnam</tt> to obtain
--   the <tt>GroupEntry</tt> information associated with the group called
--   <tt>name</tt>.
getGroupEntryForName :: String -> IO GroupEntry

-- | <tt>getAllGroupEntries</tt> returns all group entries on the system by
--   repeatedly calling <tt>getgrent</tt>
getAllGroupEntries :: IO [GroupEntry]
data UserEntry
UserEntry :: String -> String -> UserID -> GroupID -> String -> String -> String -> UserEntry

-- | Textual name of this user (pw_name)
userName :: UserEntry -> String

-- | Password -- may be empty or fake if shadow is in use (pw_passwd)
userPassword :: UserEntry -> String

-- | Numeric ID for this user (pw_uid)
userID :: UserEntry -> UserID

-- | Primary group ID (pw_gid)
userGroupID :: UserEntry -> GroupID

-- | Usually the real name for the user (pw_gecos)
userGecos :: UserEntry -> String

-- | Home directory (pw_dir)
homeDirectory :: UserEntry -> String

-- | Default shell (pw_shell)
userShell :: UserEntry -> String

-- | <tt>getUserEntryForID gid</tt> calls <tt>getpwuid</tt> to obtain the
--   <tt>UserEntry</tt> information associated with <tt>UserID</tt>
--   <tt>uid</tt>.
getUserEntryForID :: UserID -> IO UserEntry

-- | <tt>getUserEntryForName name</tt> calls <tt>getpwnam</tt> to obtain
--   the <tt>UserEntry</tt> information associated with the user login
--   <tt>name</tt>.
getUserEntryForName :: String -> IO UserEntry

-- | <tt>getAllUserEntries</tt> returns all user entries on the system by
--   repeatedly calling <tt>getpwent</tt>
getAllUserEntries :: IO [UserEntry]

-- | <tt>setUserID uid</tt> calls <tt>setuid</tt> to set the real,
--   effective, and saved set-user-id associated with the current process
--   to <tt>uid</tt>.
setUserID :: UserID -> IO ()

-- | <tt>setGroupID gid</tt> calls <tt>setgid</tt> to set the real,
--   effective, and saved set-group-id associated with the current process
--   to <tt>gid</tt>.
setGroupID :: GroupID -> IO ()

-- | <tt>setEffectiveUserID uid</tt> calls <tt>seteuid</tt> to set the
--   effective user-id associated with the current process to <tt>uid</tt>.
--   This does not update the real user-id or set-user-id.
setEffectiveUserID :: UserID -> IO ()

-- | <tt>setEffectiveGroupID uid</tt> calls <tt>setegid</tt> to set the
--   effective group-id associated with the current process to
--   <tt>gid</tt>. This does not update the real group-id or set-group-id.
setEffectiveGroupID :: GroupID -> IO ()

-- | <tt>setGroups</tt> calls <tt>setgroups</tt> to set the list of
--   supplementary <tt>GroupID</tt>s associated with the current process.
setGroups :: [GroupID] -> IO ()
instance Show GroupEntry
instance Read GroupEntry
instance Eq GroupEntry
instance Show UserEntry
instance Read UserEntry
instance Eq UserEntry


-- | POSIX Time support
module System.Posix.Time

-- | <tt>epochTime</tt> calls <tt>time</tt> to obtain the number of seconds
--   that have elapsed since the epoch (Jan 01 00:00:00 GMT 1970).
epochTime :: IO EpochTime


-- | POSIX process support. See also the System.Cmd and System.Process
--   modules in the process package.
module System.Posix.Process

-- | <a>forkProcess</a> corresponds to the POSIX <tt>fork</tt> system call.
--   The <a>IO</a> action passed as an argument is executed in the child
--   process; no other threads will be copied to the child process. On
--   success, <a>forkProcess</a> returns the child's <a>ProcessID</a> to
--   the parent process; in case of an error, an exception is thrown.
--   
--   <a>forkProcess</a> comes with a giant warning: since any other running
--   threads are not copied into the child process, it's easy to go wrong:
--   e.g. by accessing some shared resource that was held by another thread
--   in the parent.
--   
--   GHC note: <a>forkProcess</a> is not currently supported when using
--   multiple processors (<tt>+RTS -N</tt>), although it is supported with
--   <tt>-threaded</tt> as long as only one processor is being used.
forkProcess :: IO () -> IO ProcessID

-- | <tt><a>executeFile</a> cmd args env</tt> calls one of the
--   <tt>execv*</tt> family, depending on whether or not the current PATH
--   is to be searched for the command, and whether or not an environment
--   is provided to supersede the process's current environment. The
--   basename (leading directory names suppressed) of the command is passed
--   to <tt>execv*</tt> as <tt>arg[0]</tt>; the argument list passed to
--   <a>executeFile</a> therefore begins with <tt>arg[1]</tt>.
executeFile :: FilePath -> Bool -> [String] -> Maybe [(String, String)] -> IO a

-- | <tt><a>exitImmediately</a> status</tt> calls <tt>_exit</tt> to
--   terminate the process with the indicated exit <tt>status</tt>. The
--   operation never returns.
exitImmediately :: ExitCode -> IO ()

-- | <a>getProcessID</a> calls <tt>getpid</tt> to obtain the
--   <a>ProcessID</a> for the current process.
getProcessID :: IO ProcessID

-- | <a>getProcessID</a> calls <tt>getppid</tt> to obtain the
--   <a>ProcessID</a> for the parent of the current process.
getParentProcessID :: IO ProcessID

-- | <a>getProcessGroupID</a> calls <tt>getpgrp</tt> to obtain the
--   <a>ProcessGroupID</a> for the current process.
getProcessGroupID :: IO ProcessGroupID

-- | <tt><a>createProcessGroup</a> pid</tt> calls <tt>setpgid</tt> to make
--   process <tt>pid</tt> a new process group leader.
createProcessGroup :: ProcessID -> IO ProcessGroupID

-- | <tt><a>joinProcessGroup</a> pgid</tt> calls <tt>setpgid</tt> to set
--   the <a>ProcessGroupID</a> of the current process to <tt>pgid</tt>.
joinProcessGroup :: ProcessGroupID -> IO ()

-- | <tt><a>setProcessGroupID</a> pid pgid</tt> calls <tt>setpgid</tt> to
--   set the <a>ProcessGroupID</a> for process <tt>pid</tt> to
--   <tt>pgid</tt>.
setProcessGroupID :: ProcessID -> ProcessGroupID -> IO ()

-- | <a>createSession</a> calls <tt>setsid</tt> to create a new session
--   with the current process as session leader.
createSession :: IO ProcessGroupID
data ProcessTimes
ProcessTimes :: ClockTick -> ClockTick -> ClockTick -> ClockTick -> ClockTick -> ProcessTimes
elapsedTime :: ProcessTimes -> ClockTick
userTime :: ProcessTimes -> ClockTick
systemTime :: ProcessTimes -> ClockTick
childUserTime :: ProcessTimes -> ClockTick
childSystemTime :: ProcessTimes -> ClockTick

-- | <a>getProcessTimes</a> calls <tt>times</tt> to obtain time-accounting
--   information for the current process and its children.
getProcessTimes :: IO ProcessTimes
nice :: Int -> IO ()
getProcessPriority :: ProcessID -> IO Int
getProcessGroupPriority :: ProcessGroupID -> IO Int
getUserPriority :: UserID -> IO Int
setProcessPriority :: ProcessID -> Int -> IO ()
setProcessGroupPriority :: ProcessGroupID -> Int -> IO ()
setUserPriority :: UserID -> Int -> IO ()
data ProcessStatus
Exited :: ExitCode -> ProcessStatus
Terminated :: Signal -> ProcessStatus
Stopped :: Signal -> ProcessStatus

-- | <tt><a>getProcessStatus</a> blk stopped pid</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> tc</tt>, the
--   <a>ProcessStatus</a> for process <tt>pid</tt> if it is available,
--   <a>Nothing</a> otherwise. If <tt>blk</tt> is <a>False</a>, then
--   <tt>WNOHANG</tt> is set in the options for <tt>waitpid</tt>, otherwise
--   not. If <tt>stopped</tt> is <a>True</a>, then <tt>WUNTRACED</tt> is
--   set in the options for <tt>waitpid</tt>, otherwise not.
getProcessStatus :: Bool -> Bool -> ProcessID -> IO (Maybe ProcessStatus)

-- | <tt><a>getAnyProcessStatus</a> blk stopped</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> (pid, tc)</tt>, the
--   <a>ProcessID</a> and <a>ProcessStatus</a> for any child process if one
--   is available, <a>Nothing</a> otherwise. If <tt>blk</tt> is
--   <a>False</a>, then <tt>WNOHANG</tt> is set in the options for
--   <tt>waitpid</tt>, otherwise not. If <tt>stopped</tt> is <a>True</a>,
--   then <tt>WUNTRACED</tt> is set in the options for <tt>waitpid</tt>,
--   otherwise not.
getAnyProcessStatus :: Bool -> Bool -> IO (Maybe (ProcessID, ProcessStatus))

-- | <tt><a>getGroupProcessStatus</a> blk stopped pgid</tt> calls
--   <tt>waitpid</tt>, returning <tt><a>Just</a> (pid, tc)</tt>, the
--   <a>ProcessID</a> and <a>ProcessStatus</a> for any process in group
--   <tt>pgid</tt> if one is available, <a>Nothing</a> otherwise. If
--   <tt>blk</tt> is <a>False</a>, then <tt>WNOHANG</tt> is set in the
--   options for <tt>waitpid</tt>, otherwise not. If <tt>stopped</tt> is
--   <a>True</a>, then <tt>WUNTRACED</tt> is set in the options for
--   <tt>waitpid</tt>, otherwise not.
getGroupProcessStatus :: Bool -> Bool -> ProcessGroupID -> IO (Maybe (ProcessID, ProcessStatus))


-- | POSIX environment support
module System.Posix.Env

-- | <a>getEnv</a> looks up a variable in the environment.
getEnv :: String -> IO (Maybe String)

-- | <a>getEnvDefault</a> is a wrapper around <a>getEnv</a> where the
--   programmer can specify a fallback if the variable is not found in the
--   environment.
getEnvDefault :: String -> String -> IO String
getEnvironmentPrim :: IO [String]

-- | <a>getEnvironment</a> retrieves the entire environment as a list of
--   <tt>(key,value)</tt> pairs.
getEnvironment :: IO [(String, String)]

-- | <a>putEnv</a> function takes an argument of the form
--   <tt>name=value</tt> and is equivalent to
--   <tt>setEnv(key,value,True{-overwrite-})</tt>.
putEnv :: String -> IO ()

-- | The <a>setEnv</a> function inserts or resets the environment variable
--   name in the current environment list. If the variable <tt>name</tt>
--   does not exist in the list, it is inserted with the given value. If
--   the variable does exist, the argument <tt>overwrite</tt> is tested; if
--   <tt>overwrite</tt> is <tt>False</tt>, the variable is not reset,
--   otherwise it is reset to the given value.
setEnv :: String -> String -> Bool -> IO ()

-- | The <a>unsetEnv</a> function deletes all instances of the variable
--   name from the environment.
unsetEnv :: String -> IO ()


-- | POSIX IO support. These types and functions correspond to the unix
--   functions open(2), close(2), etc. For more portable functions which
--   are more like fopen(3) and friends from stdio.h, see <a>System.IO</a>.
module System.Posix.IO
stdInput :: Fd
stdOutput :: Fd
stdError :: Fd
data OpenMode
ReadOnly :: OpenMode
WriteOnly :: OpenMode
ReadWrite :: OpenMode

-- | Correspond to some of the int flags from C's fcntl.h.
data OpenFileFlags
OpenFileFlags :: Bool -> Bool -> Bool -> Bool -> Bool -> OpenFileFlags

-- | O_APPEND
append :: OpenFileFlags -> Bool

-- | O_EXCL
exclusive :: OpenFileFlags -> Bool

-- | O_NOCTTY
noctty :: OpenFileFlags -> Bool

-- | O_NONBLOCK
nonBlock :: OpenFileFlags -> Bool

-- | O_TRUNC
trunc :: OpenFileFlags -> Bool

-- | Default values for the <a>OpenFileFlags</a> type. False for each of
--   append, exclusive, noctty, nonBlock, and trunc.
defaultFileFlags :: OpenFileFlags

-- | Open and optionally create this file. See <tt>System.Posix.Files</tt>
--   for information on how to use the <a>FileMode</a> type.
openFd :: FilePath -> OpenMode -> Maybe FileMode -> OpenFileFlags -> IO Fd

-- | Create and open this file in WriteOnly mode. A special case of
--   <a>openFd</a>. See <tt>System.Posix.Files</tt> for information on how
--   to use the <a>FileMode</a> type.
createFile :: FilePath -> FileMode -> IO Fd

-- | Close this file descriptor. May throw an exception if this is an
--   invalid descriptor.
closeFd :: Fd -> IO ()

-- | Read data from an <a>Fd</a> and convert it to a <a>String</a>. Throws
--   an exception if this is an invalid descriptor, or EOF has been
--   reached.
fdRead :: Fd -> ByteCount -> IO (String, ByteCount)

-- | Write a <a>String</a> to an <a>Fd</a> (no character conversion is
--   done, the least-significant 8 bits of each character are written).
fdWrite :: Fd -> String -> IO ByteCount

-- | Read data from an <a>Fd</a> into memory. This is exactly equivalent to
--   the POSIX <tt>read</tt> function.
fdReadBuf :: Fd -> Ptr Word8 -> ByteCount -> IO ByteCount

-- | Write data from memory to an <a>Fd</a>. This is exactly equivalent to
--   the POSIX <tt>write</tt> function.
fdWriteBuf :: Fd -> Ptr Word8 -> ByteCount -> IO ByteCount

-- | May throw an exception if this is an invalid descriptor.
fdSeek :: Fd -> SeekMode -> FileOffset -> IO FileOffset
data FdOption

-- | O_APPEND
AppendOnWrite :: FdOption

-- | FD_CLOEXEC
CloseOnExec :: FdOption

-- | O_NONBLOCK
NonBlockingRead :: FdOption

-- | O_SYNC
SynchronousWrites :: FdOption

-- | May throw an exception if this is an invalid descriptor.
queryFdOption :: Fd -> FdOption -> IO Bool

-- | May throw an exception if this is an invalid descriptor.
setFdOption :: Fd -> FdOption -> Bool -> IO ()
type FileLock = (LockRequest, SeekMode, FileOffset, FileOffset)
data LockRequest
ReadLock :: LockRequest
WriteLock :: LockRequest
Unlock :: LockRequest

-- | May throw an exception if this is an invalid descriptor.
getLock :: Fd -> FileLock -> IO (Maybe (ProcessID, FileLock))

-- | May throw an exception if this is an invalid descriptor.
setLock :: Fd -> FileLock -> IO ()

-- | May throw an exception if this is an invalid descriptor.
waitToSetLock :: Fd -> FileLock -> IO ()

-- | The <a>createPipe</a> function creates a pair of connected file
--   descriptors. The first component is the fd to read from, the second is
--   the write end. Although pipes may be bidirectional, this behaviour is
--   not portable and programmers should use two separate pipes for this
--   purpose. May throw an exception if this is an invalid descriptor.
createPipe :: IO (Fd, Fd)

-- | May throw an exception if this is an invalid descriptor.
dup :: Fd -> IO Fd

-- | May throw an exception if this is an invalid descriptor.
dupTo :: Fd -> Fd -> IO Fd

-- | Extracts the <a>Fd</a> from a <a>Handle</a>. This function has the
--   side effect of closing the <a>Handle</a> and flushing its write
--   buffer, if necessary.
handleToFd :: Handle -> IO Fd

-- | Converts an <a>Fd</a> into a <a>Handle</a> that can be used with the
--   standard Haskell IO library (see <a>System.IO</a>).
--   
--   GHC only: this function has the side effect of putting the <a>Fd</a>
--   into non-blocking mode (<tt>O_NONBLOCK</tt>) due to the way the
--   standard IO library implements multithreaded I/O.
fdToHandle :: Fd -> IO Handle


-- | POSIX environment support
module System.Posix.Temp

-- | <a>mkstemp</a> - make a unique filename and open it for
--   reading/writing (only safe on GHC &amp; Hugs). The returned
--   <a>FilePath</a> is the (possibly relative) path of the created file,
--   which is padded with 6 random characters.
mkstemp :: String -> IO (FilePath, Handle)


-- | POSIX Terminal support
module System.Posix.Terminal
data TerminalAttributes

-- | <tt>getTerminalAttributes fd</tt> calls <tt>tcgetattr</tt> to obtain
--   the <tt>TerminalAttributes</tt> associated with <tt>Fd</tt>
--   <tt>fd</tt>.
getTerminalAttributes :: Fd -> IO TerminalAttributes
data TerminalState
Immediately :: TerminalState
WhenDrained :: TerminalState
WhenFlushed :: TerminalState

-- | <tt>setTerminalAttributes fd attr ts</tt> calls <tt>tcsetattr</tt> to
--   change the <tt>TerminalAttributes</tt> associated with <tt>Fd</tt>
--   <tt>fd</tt> to <tt>attr</tt>, when the terminal is in the state
--   indicated by <tt>ts</tt>.
setTerminalAttributes :: Fd -> TerminalAttributes -> TerminalState -> IO ()
data TerminalMode
InterruptOnBreak :: TerminalMode
MapCRtoLF :: TerminalMode
IgnoreBreak :: TerminalMode
IgnoreCR :: TerminalMode
IgnoreParityErrors :: TerminalMode
MapLFtoCR :: TerminalMode
CheckParity :: TerminalMode
StripHighBit :: TerminalMode
StartStopInput :: TerminalMode
StartStopOutput :: TerminalMode
MarkParityErrors :: TerminalMode
ProcessOutput :: TerminalMode
LocalMode :: TerminalMode
ReadEnable :: TerminalMode
TwoStopBits :: TerminalMode
HangupOnClose :: TerminalMode
EnableParity :: TerminalMode
OddParity :: TerminalMode
EnableEcho :: TerminalMode
EchoErase :: TerminalMode
EchoKill :: TerminalMode
EchoLF :: TerminalMode
ProcessInput :: TerminalMode
ExtendedFunctions :: TerminalMode
KeyboardInterrupts :: TerminalMode
NoFlushOnInterrupt :: TerminalMode
BackgroundWriteInterrupt :: TerminalMode
withoutMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
withMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
terminalMode :: TerminalMode -> TerminalAttributes -> Bool
bitsPerByte :: TerminalAttributes -> Int
withBits :: TerminalAttributes -> Int -> TerminalAttributes
data ControlCharacter
EndOfFile :: ControlCharacter
EndOfLine :: ControlCharacter
Erase :: ControlCharacter
Interrupt :: ControlCharacter
Kill :: ControlCharacter
Quit :: ControlCharacter
Start :: ControlCharacter
Stop :: ControlCharacter
Suspend :: ControlCharacter
controlChar :: TerminalAttributes -> ControlCharacter -> Maybe Char
withCC :: TerminalAttributes -> (ControlCharacter, Char) -> TerminalAttributes
withoutCC :: TerminalAttributes -> ControlCharacter -> TerminalAttributes
inputTime :: TerminalAttributes -> Int
withTime :: TerminalAttributes -> Int -> TerminalAttributes
minInput :: TerminalAttributes -> Int
withMinInput :: TerminalAttributes -> Int -> TerminalAttributes
data BaudRate
B0 :: BaudRate
B50 :: BaudRate
B75 :: BaudRate
B110 :: BaudRate
B134 :: BaudRate
B150 :: BaudRate
B200 :: BaudRate
B300 :: BaudRate
B600 :: BaudRate
B1200 :: BaudRate
B1800 :: BaudRate
B2400 :: BaudRate
B4800 :: BaudRate
B9600 :: BaudRate
B19200 :: BaudRate
B38400 :: BaudRate
B57600 :: BaudRate
B115200 :: BaudRate
inputSpeed :: TerminalAttributes -> BaudRate
withInputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes
outputSpeed :: TerminalAttributes -> BaudRate
withOutputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes

-- | <tt>sendBreak fd duration</tt> calls <tt>tcsendbreak</tt> to transmit
--   a continuous stream of zero-valued bits on <tt>Fd</tt> <tt>fd</tt> for
--   the specified implementation-dependent <tt>duration</tt>.
sendBreak :: Fd -> Int -> IO ()

-- | <tt>drainOutput fd</tt> calls <tt>tcdrain</tt> to block until all
--   output written to <tt>Fd</tt> <tt>fd</tt> has been transmitted.
drainOutput :: Fd -> IO ()
data QueueSelector
InputQueue :: QueueSelector
OutputQueue :: QueueSelector
BothQueues :: QueueSelector

-- | <tt>discardData fd queues</tt> calls <tt>tcflush</tt> to discard
--   pending input and/or output for <tt>Fd</tt> <tt>fd</tt>, as indicated
--   by the <tt>QueueSelector</tt> <tt>queues</tt>.
discardData :: Fd -> QueueSelector -> IO ()
data FlowAction

-- | TCOOFF
SuspendOutput :: FlowAction

-- | TCOON
RestartOutput :: FlowAction

-- | TCIOFF
TransmitStop :: FlowAction

-- | TCION
TransmitStart :: FlowAction

-- | <tt>controlFlow fd action</tt> calls <tt>tcflow</tt> to control the
--   flow of data on <tt>Fd</tt> <tt>fd</tt>, as indicated by
--   <tt>action</tt>.
controlFlow :: Fd -> FlowAction -> IO ()

-- | <tt>getTerminalProcessGroupID fd</tt> calls <tt>tcgetpgrp</tt> to
--   obtain the <tt>ProcessGroupID</tt> of the foreground process group
--   associated with the terminal attached to <tt>Fd</tt> <tt>fd</tt>.
getTerminalProcessGroupID :: Fd -> IO ProcessGroupID

-- | <tt>setTerminalProcessGroupID fd pgid</tt> calls <tt>tcsetpgrp</tt> to
--   set the <tt>ProcessGroupID</tt> of the foreground process group
--   associated with the terminal attached to <tt>Fd</tt> <tt>fd</tt> to
--   <tt>pgid</tt>.
setTerminalProcessGroupID :: Fd -> ProcessGroupID -> IO ()

-- | <tt>queryTerminal fd</tt> calls <tt>isatty</tt> to determine whether
--   or not <tt>Fd</tt> <tt>fd</tt> is associated with a terminal.
queryTerminal :: Fd -> IO Bool

-- | <tt>getTerminalName fd</tt> calls <tt>ttyname</tt> to obtain a name
--   associated with the terminal for <tt>Fd</tt> <tt>fd</tt>. If
--   <tt>fd</tt> is associated with a terminal, <tt>getTerminalName</tt>
--   returns the name of the terminal.
getTerminalName :: Fd -> IO FilePath

-- | <tt>getControllingTerminalName</tt> calls <tt>ctermid</tt> to obtain a
--   name associated with the controlling terminal for the process. If a
--   controlling terminal exists, <tt>getControllingTerminalName</tt>
--   returns the name of the controlling terminal.
getControllingTerminalName :: IO FilePath

-- | <tt>openPseudoTerminal</tt> creates a pseudoterminal (pty) pair, and
--   returns the newly created pair as a (<tt>master</tt>, <tt>slave</tt>)
--   tuple.
openPseudoTerminal :: IO (Fd, Fd)

-- | <tt>getSlaveTerminalName</tt> calls <tt>ptsname</tt> to obtain the
--   name of the slave terminal associated with a pseudoterminal pair. The
--   file descriptor to pass in must be that of the master.
getSlaveTerminalName :: Fd -> IO FilePath


-- | POSIX miscellaneous stuff, mostly from unistd.h
module System.Posix.Unistd
data SystemID
SystemID :: String -> String -> String -> String -> String -> SystemID
systemName :: SystemID -> String
nodeName :: SystemID -> String
release :: SystemID -> String
version :: SystemID -> String
machine :: SystemID -> String
getSystemID :: IO SystemID
data SysVar
ArgumentLimit :: SysVar
ChildLimit :: SysVar
ClockTick :: SysVar
GroupLimit :: SysVar
OpenFileLimit :: SysVar
PosixVersion :: SysVar
HasSavedIDs :: SysVar
HasJobControl :: SysVar
getSysVar :: SysVar -> IO Integer

-- | Sleep for the specified duration (in seconds). Returns the time
--   remaining (if the sleep was interrupted by a signal, for example).
--   
--   GHC Note: the comment for <a>usleep</a> also applies here.
sleep :: Int -> IO Int

-- | Sleep for the specified duration (in microseconds).
--   
--   GHC Note: <tt>Control.Concurrent.threadDelay</tt> is a better choice.
--   Without the <tt>-threaded</tt> option, <a>usleep</a> will block all
--   other user threads. Even with the <tt>-threaded</tt> option,
--   <a>usleep</a> requires a full OS thread to itself.
--   <tt>Control.Concurrent.threadDelay</tt> has neither of these
--   shortcomings.
usleep :: Int -> IO ()

-- | Sleep for the specified duration (in nanoseconds)
nanosleep :: Integer -> IO ()


-- | Functions defined by the POSIX standards for manipulating and querying
--   the file system. Names of underlying POSIX functions are indicated
--   whenever possible. A more complete documentation of the POSIX
--   functions together with a more detailed description of different error
--   conditions are usually available in the system's manual pages or from
--   <a>http://www.unix.org/version3/online.html</a> (free registration
--   required).
--   
--   When a function that calls an underlying POSIX function fails, the
--   errno code is converted to an <a>IOError</a> using
--   <tt>Foreign.C.Error.errnoToIOError</tt>. For a list of which errno
--   codes may be generated, consult the POSIX documentation for the
--   underlying function.
module System.Posix.Files

-- | Combines the two file modes into one that contains modes that appear
--   in either.
unionFileModes :: FileMode -> FileMode -> FileMode

-- | Combines two file modes into one that only contains modes that appear
--   in both.
intersectFileModes :: FileMode -> FileMode -> FileMode

-- | No permissions.
nullFileMode :: FileMode

-- | Owner has read permission.
ownerReadMode :: FileMode

-- | Owner has write permission.
ownerWriteMode :: FileMode

-- | Owner has execute permission.
ownerExecuteMode :: FileMode

-- | Owner has read, write and execute permission.
ownerModes :: FileMode

-- | Group has read permission.
groupReadMode :: FileMode

-- | Group has write permission.
groupWriteMode :: FileMode

-- | Group has execute permission.
groupExecuteMode :: FileMode

-- | Group has read, write and execute permission.
groupModes :: FileMode

-- | Others have read permission.
otherReadMode :: FileMode

-- | Others have write permission.
otherWriteMode :: FileMode

-- | Others have execute permission.
otherExecuteMode :: FileMode

-- | Others have read, write and execute permission.
otherModes :: FileMode

-- | Set user ID on execution.
setUserIDMode :: FileMode

-- | Set group ID on execution.
setGroupIDMode :: FileMode

-- | Owner, group and others have read and write permission.
stdFileMode :: FileMode

-- | Owner, group and others have read, write and execute permission.
accessModes :: FileMode
fileTypeModes :: FileMode
blockSpecialMode :: FileMode
characterSpecialMode :: FileMode
namedPipeMode :: FileMode
regularFileMode :: FileMode
directoryMode :: FileMode
symbolicLinkMode :: FileMode
socketMode :: FileMode

-- | <tt>setFileMode path mode</tt> changes permission of the file given by
--   <tt>path</tt> to <tt>mode</tt>. This operation may fail with
--   <a>throwErrnoPathIfMinus1_</a> if <tt>path</tt> doesn't exist or if
--   the effective user ID of the current process is not that of the file's
--   owner.
--   
--   Note: calls <tt>chmod</tt>.
setFileMode :: FilePath -> FileMode -> IO ()

-- | <tt>setFdMode fd mode</tt> acts like <a>setFileMode</a> but uses a
--   file descriptor <tt>fd</tt> instead of a <a>FilePath</a>.
--   
--   Note: calls <tt>fchmod</tt>.
setFdMode :: Fd -> FileMode -> IO ()

-- | <tt>setFileCreationMask mode</tt> sets the file mode creation mask to
--   <tt>mode</tt>. Modes set by this operation are subtracted from files
--   and directories upon creation. The previous file creation mask is
--   returned.
--   
--   Note: calls <tt>umask</tt>.
setFileCreationMask :: FileMode -> IO FileMode

-- | <tt>fileAccess name read write exec</tt> checks if the file (or other
--   file system object) <tt>name</tt> can be accessed for reading, writing
--   and/or executing. To check a permission set the corresponding argument
--   to <a>True</a>.
--   
--   Note: calls <tt>access</tt>.
fileAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool

-- | Checks for the existence of the file.
--   
--   Note: calls <tt>access</tt>.
fileExist :: FilePath -> IO Bool

-- | POSIX defines operations to get information, such as owner,
--   permissions, size and access times, about a file. This information is
--   represented by the <a>FileStatus</a> type.
--   
--   Note: see <tt>chmod</tt>.
data FileStatus

-- | <tt>getFileStatus path</tt> calls gets the <tt>FileStatus</tt>
--   information (user ID, size, access times, etc.) for the file
--   <tt>path</tt>.
--   
--   Note: calls <tt>stat</tt>.
getFileStatus :: FilePath -> IO FileStatus

-- | <tt>getFdStatus fd</tt> acts as <a>getFileStatus</a> but uses a file
--   descriptor <tt>fd</tt>.
--   
--   Note: calls <tt>fstat</tt>.
getFdStatus :: Fd -> IO FileStatus

-- | Acts as <a>getFileStatus</a> except when the <a>FilePath</a> refers to
--   a symbolic link. In that case the <tt>FileStatus</tt> information of
--   the symbolic link itself is returned instead of that of the file it
--   points to.
--   
--   Note: calls <tt>lstat</tt>.
getSymbolicLinkStatus :: FilePath -> IO FileStatus

-- | ID of the device on which this file resides.
deviceID :: FileStatus -> DeviceID

-- | inode number
fileID :: FileStatus -> FileID

-- | File mode (such as permissions).
fileMode :: FileStatus -> FileMode

-- | Number of hard links to this file.
linkCount :: FileStatus -> LinkCount

-- | ID of owner.
fileOwner :: FileStatus -> UserID

-- | ID of group.
fileGroup :: FileStatus -> GroupID

-- | Describes the device that this file represents.
specialDeviceID :: FileStatus -> DeviceID

-- | Size of the file in bytes. If this file is a symbolic link the size is
--   the length of the pathname it contains.
fileSize :: FileStatus -> FileOffset

-- | Time of last access.
accessTime :: FileStatus -> EpochTime

-- | Time of last modification.
modificationTime :: FileStatus -> EpochTime

-- | Time of last status change (i.e. owner, group, link count, mode,
--   etc.).
statusChangeTime :: FileStatus -> EpochTime

-- | Checks if this file is a block device.
isBlockDevice :: FileStatus -> Bool

-- | Checks if this file is a character device.
isCharacterDevice :: FileStatus -> Bool

-- | Checks if this file is a named pipe device.
isNamedPipe :: FileStatus -> Bool

-- | Checks if this file is a regular file device.
isRegularFile :: FileStatus -> Bool

-- | Checks if this file is a directory device.
isDirectory :: FileStatus -> Bool

-- | Checks if this file is a symbolic link device.
isSymbolicLink :: FileStatus -> Bool

-- | Checks if this file is a socket device.
isSocket :: FileStatus -> Bool

-- | <tt>createNamedPipe fifo mode</tt> creates a new named pipe,
--   <tt>fifo</tt>, with permissions based on <tt>mode</tt>. May fail with
--   <a>throwErrnoPathIfMinus1_</a> if a file named <tt>name</tt> already
--   exists or if the effective user ID of the current process doesn't have
--   permission to create the pipe.
--   
--   Note: calls <tt>mkfifo</tt>.
createNamedPipe :: FilePath -> FileMode -> IO ()

-- | <tt>createDevice path mode dev</tt> creates either a regular or a
--   special file depending on the value of <tt>mode</tt> (and
--   <tt>dev</tt>). <tt>mode</tt> will normally be either
--   <a>blockSpecialMode</a> or <a>characterSpecialMode</a>. May fail with
--   <a>throwErrnoPathIfMinus1_</a> if a file named <tt>name</tt> already
--   exists or if the effective user ID of the current process doesn't have
--   permission to create the file.
--   
--   Note: calls <tt>mknod</tt>.
createDevice :: FilePath -> FileMode -> DeviceID -> IO ()

-- | <tt>createLink old new</tt> creates a new path, <tt>new</tt>, linked
--   to an existing file, <tt>old</tt>.
--   
--   Note: calls <tt>link</tt>.
createLink :: FilePath -> FilePath -> IO ()

-- | <tt>removeLink path</tt> removes the link named <tt>path</tt>.
--   
--   Note: calls <tt>unlink</tt>.
removeLink :: FilePath -> IO ()

-- | <tt>createSymbolicLink file1 file2</tt> creates a symbolic link named
--   <tt>file2</tt> which points to the file <tt>file1</tt>.
--   
--   Symbolic links are interpreted at run-time as if the contents of the
--   link had been substituted into the path being followed to find a file
--   or directory.
--   
--   Note: calls <tt>symlink</tt>.
createSymbolicLink :: FilePath -> FilePath -> IO ()

-- | Reads the <tt>FilePath</tt> pointed to by the symbolic link and
--   returns it.
--   
--   Note: calls <tt>readlink</tt>.
readSymbolicLink :: FilePath -> IO FilePath

-- | <tt>rename old new</tt> renames a file or directory from <tt>old</tt>
--   to <tt>new</tt>.
--   
--   Note: calls <tt>rename</tt>.
rename :: FilePath -> FilePath -> IO ()

-- | <tt>setOwnerAndGroup path uid gid</tt> changes the owner and group of
--   <tt>path</tt> to <tt>uid</tt> and <tt>gid</tt>, respectively.
--   
--   If <tt>uid</tt> or <tt>gid</tt> is specified as -1, then that ID is
--   not changed.
--   
--   Note: calls <tt>chown</tt>.
setOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()

-- | Acts as <a>setOwnerAndGroup</a> but uses a file descriptor instead of
--   a <a>FilePath</a>.
--   
--   Note: calls <tt>fchown</tt>.
setFdOwnerAndGroup :: Fd -> UserID -> GroupID -> IO ()

-- | Acts as <a>setOwnerAndGroup</a> but does not follow symlinks (and thus
--   changes permissions on the link itself).
--   
--   Note: calls <tt>lchown</tt>.
setSymbolicLinkOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()

-- | <tt>setFileTimes path atime mtime</tt> sets the access and
--   modification times associated with file <tt>path</tt> to
--   <tt>atime</tt> and <tt>mtime</tt>, respectively.
--   
--   Note: calls <tt>utime</tt>.
setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO ()

-- | <tt>touchFile path</tt> sets the access and modification times
--   associated with file <tt>path</tt> to the current time.
--   
--   Note: calls <tt>utime</tt>.
touchFile :: FilePath -> IO ()

-- | Truncates the file down to the specified length. If the file was
--   larger than the given length before this operation was performed the
--   extra is lost.
--   
--   Note: calls <tt>truncate</tt>.
setFileSize :: FilePath -> FileOffset -> IO ()

-- | Acts as <a>setFileSize</a> but uses a file descriptor instead of a
--   <a>FilePath</a>.
--   
--   Note: calls <tt>ftruncate</tt>.
setFdSize :: Fd -> FileOffset -> IO ()
data PathVar
FileSizeBits :: PathVar
LinkLimit :: PathVar
InputLineLimit :: PathVar
InputQueueLimit :: PathVar
FileNameLimit :: PathVar
PathNameLimit :: PathVar
PipeBufferLimit :: PathVar
SymbolicLinkLimit :: PathVar
SetOwnerAndGroupIsRestricted :: PathVar
FileNamesAreNotTruncated :: PathVar
VDisableChar :: PathVar
AsyncIOAvailable :: PathVar
PrioIOAvailable :: PathVar
SyncIOAvailable :: PathVar

-- | <tt>getPathVar var path</tt> obtains the dynamic value of the
--   requested configurable file limit or option associated with file or
--   directory <tt>path</tt>. For defined file limits, <tt>getPathVar</tt>
--   returns the associated value. For defined file options, the result of
--   <tt>getPathVar</tt> is undefined, but not failure.
--   
--   Note: calls <tt>pathconf</tt>.
getPathVar :: FilePath -> PathVar -> IO Limit

-- | <tt>getFdPathVar var fd</tt> obtains the dynamic value of the
--   requested configurable file limit or option associated with the file
--   or directory attached to the open channel <tt>fd</tt>. For defined
--   file limits, <tt>getFdPathVar</tt> returns the associated value. For
--   defined file options, the result of <tt>getFdPathVar</tt> is
--   undefined, but not failure.
--   
--   Note: calls <tt>fpathconf</tt>.
getFdPathVar :: Fd -> PathVar -> IO Limit


-- | POSIX directory support
module System.Posix.Directory

-- | <tt>createDirectory dir mode</tt> calls <tt>mkdir</tt> to create a new
--   directory, <tt>dir</tt>, with permissions based on <tt>mode</tt>.
createDirectory :: FilePath -> FileMode -> IO ()
removeDirectory :: FilePath -> IO ()
data DirStream

-- | <tt>openDirStream dir</tt> calls <tt>opendir</tt> to obtain a
--   directory stream for <tt>dir</tt>.
openDirStream :: FilePath -> IO DirStream

-- | <tt>readDirStream dp</tt> calls <tt>readdir</tt> to obtain the next
--   directory entry (<tt>struct dirent</tt>) for the open directory stream
--   <tt>dp</tt>, and returns the <tt>d_name</tt> member of that structure.
readDirStream :: DirStream -> IO FilePath

-- | <tt>rewindDirStream dp</tt> calls <tt>rewinddir</tt> to reposition the
--   directory stream <tt>dp</tt> at the beginning of the directory.
rewindDirStream :: DirStream -> IO ()

-- | <tt>closeDirStream dp</tt> calls <tt>closedir</tt> to close the
--   directory stream <tt>dp</tt>.
closeDirStream :: DirStream -> IO ()
data DirStreamOffset
tellDirStream :: DirStream -> IO DirStreamOffset
seekDirStream :: DirStream -> DirStreamOffset -> IO ()

-- | <tt>getWorkingDirectory</tt> calls <tt>getcwd</tt> to obtain the name
--   of the current working directory.
getWorkingDirectory :: IO FilePath

-- | <tt>changeWorkingDirectory dir</tt> calls <tt>chdir</tt> to change the
--   current working directory to <tt>dir</tt>.
changeWorkingDirectory :: FilePath -> IO ()
changeWorkingDirectoryFd :: Fd -> IO ()


-- | POSIX signal support
module System.Posix.Signals
type Signal = CInt
nullSignal :: Signal
internalAbort :: Signal
sigABRT :: CInt
realTimeAlarm :: Signal
sigALRM :: CInt
busError :: Signal
sigBUS :: CInt
processStatusChanged :: Signal
sigCHLD :: CInt
continueProcess :: Signal
sigCONT :: CInt
floatingPointException :: Signal
sigFPE :: CInt
lostConnection :: Signal
sigHUP :: CInt
illegalInstruction :: Signal
sigILL :: CInt
keyboardSignal :: Signal
sigINT :: CInt
killProcess :: Signal
sigKILL :: CInt
openEndedPipe :: Signal
sigPIPE :: CInt
keyboardTermination :: Signal
sigQUIT :: CInt
segmentationViolation :: Signal
sigSEGV :: CInt
softwareStop :: Signal
sigSTOP :: CInt
softwareTermination :: Signal
sigTERM :: CInt
keyboardStop :: Signal
sigTSTP :: CInt
backgroundRead :: Signal
sigTTIN :: CInt
backgroundWrite :: Signal
sigTTOU :: CInt
userDefinedSignal1 :: Signal
sigUSR1 :: CInt
userDefinedSignal2 :: Signal
sigUSR2 :: CInt
profilingTimerExpired :: Signal
sigPROF :: CInt
badSystemCall :: Signal
sigSYS :: CInt
breakpointTrap :: Signal
sigTRAP :: CInt
urgentDataAvailable :: Signal
sigURG :: CInt
virtualTimerExpired :: Signal
sigVTALRM :: CInt
cpuTimeLimitExceeded :: Signal
sigXCPU :: CInt
fileSizeLimitExceeded :: Signal
sigXFSZ :: CInt

-- | <tt>raiseSignal int</tt> calls <tt>kill</tt> to signal the current
--   process with interrupt signal <tt>int</tt>.
raiseSignal :: Signal -> IO ()

-- | <tt>signalProcess int pid</tt> calls <tt>kill</tt> to signal process
--   <tt>pid</tt> with interrupt signal <tt>int</tt>.
signalProcess :: Signal -> ProcessID -> IO ()

-- | <tt>signalProcessGroup int pgid</tt> calls <tt>kill</tt> to signal all
--   processes in group <tt>pgid</tt> with interrupt signal <tt>int</tt>.
signalProcessGroup :: Signal -> ProcessGroupID -> IO ()

-- | The actions to perform when a signal is received.
data Handler
Default :: Handler
Ignore :: Handler
Catch :: (IO ()) -> Handler
CatchOnce :: (IO ()) -> Handler

-- | <tt>installHandler int handler iset</tt> calls <tt>sigaction</tt> to
--   install an interrupt handler for signal <tt>int</tt>. If
--   <tt>handler</tt> is <tt>Default</tt>, <tt>SIG_DFL</tt> is installed;
--   if <tt>handler</tt> is <tt>Ignore</tt>, <tt>SIG_IGN</tt> is installed;
--   if <tt>handler</tt> is <tt>Catch action</tt>, a handler is installed
--   which will invoke <tt>action</tt> in a new thread when (or shortly
--   after) the signal is received. If <tt>iset</tt> is <tt>Just s</tt>,
--   then the <tt>sa_mask</tt> of the <tt>sigaction</tt> structure is set
--   to <tt>s</tt>; otherwise it is cleared. The previously installed
--   signal handler for <tt>int</tt> is returned
installHandler :: Signal -> Handler -> Maybe SignalSet -> IO Handler
data SignalSet
emptySignalSet :: SignalSet
fullSignalSet :: SignalSet

-- | A set of signals reserved for use by the implementation. In GHC, this
--   will normally include either <a>sigVTALRM</a> or <a>sigALRM</a>.
reservedSignals :: SignalSet
addSignal :: Signal -> SignalSet -> SignalSet
deleteSignal :: Signal -> SignalSet -> SignalSet
inSignalSet :: Signal -> SignalSet -> Bool

-- | <tt>getSignalMask</tt> calls <tt>sigprocmask</tt> to determine the set
--   of interrupts which are currently being blocked.
getSignalMask :: IO SignalSet

-- | <tt>setSignalMask mask</tt> calls <tt>sigprocmask</tt> with
--   <tt>SIG_SETMASK</tt> to block all interrupts in <tt>mask</tt>.
setSignalMask :: SignalSet -> IO ()

-- | <tt>blockSignals mask</tt> calls <tt>sigprocmask</tt> with
--   <tt>SIG_BLOCK</tt> to add all interrupts in <tt>mask</tt> to the set
--   of blocked interrupts.
blockSignals :: SignalSet -> IO ()

-- | <tt>unblockSignals mask</tt> calls <tt>sigprocmask</tt> with
--   <tt>SIG_UNBLOCK</tt> to remove all interrupts in <tt>mask</tt> from
--   the set of blocked interrupts.
unblockSignals :: SignalSet -> IO ()

-- | <tt>scheduleAlarm i</tt> calls <tt>alarm</tt> to schedule a real time
--   alarm at least <tt>i</tt> seconds in the future.
scheduleAlarm :: Int -> IO Int

-- | <tt>getPendingSignals</tt> calls <tt>sigpending</tt> to obtain the set
--   of interrupts which have been received but are currently blocked.
getPendingSignals :: IO SignalSet

-- | <tt>awaitSignal iset</tt> suspends execution until an interrupt is
--   received. If <tt>iset</tt> is <tt>Just s</tt>, <tt>awaitSignal</tt>
--   calls <tt>sigsuspend</tt>, installing <tt>s</tt> as the new signal
--   mask before suspending execution; otherwise, it calls
--   <tt>sigsuspend</tt> with current signal mask. Note that RTS scheduler
--   signal (either <a>virtualTimerExpired</a> or <a>realTimeAlarm</a>)
--   could cause premature termination of this call. It might be necessary
--   to block that signal before invocation of <tt>awaitSignal</tt> with
--   <a>blockSignals</a> <a>reservedSignals</a>.
--   
--   <tt>awaitSignal</tt> returns when signal was received and processed by
--   a signal handler, or if the signal could not be caught. If you have
--   installed any signal handlers with <tt>installHandler</tt>, it may be
--   wise to call <tt>yield</tt> directly after <tt>awaitSignal</tt> to
--   ensure that the signal handler runs as promptly as possible.
awaitSignal :: Maybe SignalSet -> IO ()

-- | Tells the system whether or not to set the <tt>SA_NOCLDSTOP</tt> flag
--   when installing new signal handlers.
setStoppedChildFlag :: Bool -> IO Bool

-- | Queries the current state of the stopped child flag.
queryStoppedChildFlag :: IO Bool
instance Typeable Handler


-- | non-POSIX signal support commonly available
module System.Posix.Signals.Exts
infoEvent :: Signal
sigINFO :: CInt
windowChange :: Signal
sigWINCH :: CInt


-- | POSIX support
module System.Posix
