1 <Sect1 id="Posix-library">
2 <Title>The Posix library
6 <IndexTerm><Primary>Posix library</Primary></IndexTerm>
7 <IndexTerm><Primary>libraries, Posix</Primary></IndexTerm>
11 The <Literal>Posix</Literal> interface gives you access to the set of OS
12 services standardised by POSIX 1003.1b (or the <Emphasis>IEEE Portable
13 Operating System Interface for Computing Environments</Emphasis> - IEEE Std.
14 1003.1). The interface is accessed by <Literal>import Posix</Literal> and
15 adding <Option>-syslib posix</Option> on your command-line.
18 <Sect2 id="Posix-data-types">
19 <Title>Posix data types
23 <IndexTerm><Primary>Posix, data types</Primary></IndexTerm>
29 data ByteCount -- instances of : Eq Ord Num Real Integral Ix Enum Show
35 A <Literal>ByteCount</Literal> is a primitive of type <Literal>unsigned</Literal>. At a minimum,
36 an conforming implementation must support values in the range
37 <Literal>[0, UINT_MAX]</Literal>.
43 data ClockTick -- instances of : Eq Ord Num Real Integral Ix Enum Show
49 A <Literal>ClockTick</Literal> is a primitive of type <Literal>clock_t</Literal>, which
50 is used to measure intervals of time in fractions of a second. The
51 resolution is determined by <Literal>getSysVar ClockTick</Literal>.
57 data DeviceID -- instances of : Eq Ord Num Real Integral Ix Enum Show
63 A <Literal>DeviceID</Literal> is a primitive of type <Literal>dev_t</Literal>. It must
64 be an arithmetic type.
70 data EpochTime -- instances of : Eq Ord Num Real Integral Ix Enum Show
76 A <Literal>EpochTime</Literal> is a primitive of type <Literal>time_t</Literal>, which is
77 used to measure seconds since the Epoch. At a minimum, the implementation
78 must support values in the range <Literal>[0, INT_MAX]</Literal>.
84 data FileID -- instances of : Eq Ord Num Real Integral Ix Enum Show
90 A <Literal>FileID</Literal> is a primitive of type <Literal>ino_t</Literal>. It must
91 be an arithmetic type.
97 data FileMode -- instances of : Eq Ord Num Real Integral Ix Enum Show
103 A <Literal>FileMode</Literal> is a primitive of type <Literal>mode_t</Literal>.
104 It must be an arithmetic type.
110 data FileOffset -- instances of : Eq Ord Num Real Integral Ix Enum Show
116 A <Literal>FileOffset</Literal> is a primitive of type <Literal>off_t</Literal>. It must
117 be an arithmetic type.
123 data GroupID -- instances of : Eq Ord Num Real Integral Ix Enum Show
129 A <Literal>GroupID</Literal> is a primitive of type <Literal>gid_t</Literal>. It must
130 be an arithmetic type.
133 data Limit -- instances of : Eq Ord Num Real Integral Ix Enum Show
139 A <Literal>Limit</Literal> is a primitive of type <Literal>long</Literal>.
140 At a minimum, the implementation must support values in the range
141 <Literal>[LONG_MIN, LONG_MAX]</Literal>.
147 data LinkCount -- instances of : Eq Ord Num Real Integral Ix Enum Show
153 A <Literal>LinkCount</Literal> is a primitive of type <Literal>nlink_t</Literal>. It must
154 be an arithmetic type.
160 data ProcessID -- instances of : Eq Ord Num Real Integral Ix Enum Show
161 type ProcessGroupID = ProcessID
167 A <Literal>ProcessID</Literal> is a primitive of type <Literal>pid_t</Literal>. It
168 must be a signed arithmetic type.
171 data UserID -- instances of : Eq Ord Num Real Integral Ix Enum Show
177 A <Literal>UserID</Literal> is a primitive of type <Literal>uid_t</Literal>. It
178 must be an arithmetic type.
187 A <Literal>DirStream</Literal> is a primitive of type <Literal>DIR *</Literal>.
196 A <Literal>FileStatus</Literal> is a primitive of type <Literal>struct stat</Literal>.
208 A <Literal>GroupEntry</Literal> is a primitive of type <Literal>struct group</Literal>.
217 <Literal>ProcessTimes</Literal> is a primitive structure containing a
218 <Literal>clock_t</Literal> and a <Literal>struct tms</Literal>.
230 An <Literal>SignalSet</Literal> is a primitive of type <Literal>sigset_t</Literal>.
242 A <Literal>SystemID</Literal> is a primitive of type <Literal>struct utsname</Literal>.
248 data TerminalAttributes
251 <Literal>TerminalAttributes</Literal> is a primitive of type <Literal>struct termios</Literal>.
263 A <Literal>UserEntry</Literal> is a primitive of type <Literal>struct passwd</Literal>.
269 data BaudRate = B0 | B50 | B75 | B110 | B134 | B150 | B200 | B300 | B600
270 | B1200 | B1800 | B2400 | B4800 | B9600 | B19200 | B38400
275 intToFd :: Int -> Fd -- use with care.
277 data FdOption = AppendOnWrite
281 data ControlCharacter = EndOfFile
293 type FileLock = (LockRequest, SeekMode, FileOffset, FileOffset)
294 -- whence start length
296 data FlowAction = SuspendOutput | RestartOutput | TransmitStop | TransmitStart
298 data Handler = Default | Ignore | Catch (IO ())
300 data LockRequest = ReadLock | WriteLock | Unlock
303 data OpenMode = ReadOnly | WriteOnly | ReadWrite
305 data PathVar = LinkLimit
311 | SetOwnerAndGroupIsRestricted
312 | FileNamesAreNotTruncated
314 data QueueSelector = InputQueue | OutputQueue | BothQueues
318 data SysVar = ArgumentLimit
327 data TerminalMode = InterruptOnBreak -- BRKINT
329 | IgnoreBreak -- IGNBRK
331 | IgnoreParityErrors -- IGNPAR
333 | CheckParity -- INPCK
334 | StripHighBit -- ISTRIP
335 | StartStopInput -- IXOFF
336 | StartStopOutput -- IXON
337 | MarkParityErrors -- PARMRK
338 | ProcessOutput -- OPOST
339 | LocalMode -- CLOCAL
340 | ReadEnable -- CREAD
341 | TwoStopBits -- CSTOPB
342 | HangupOnClose -- HUPCL
343 | EnableParity -- PARENB
344 | OddParity -- PARODD
349 | ProcessInput -- ICANON
350 | ExtendedFunctions -- IEXTEN
351 | KeyboardInterrupts -- ISIG
352 | NoFlushOnInterrupt -- NOFLSH
353 | BackgroundWriteInterrupt -- TOSTOP
355 data TerminalState = Immediately | WhenDrained | WhenFlushed
357 data ProcessStatus = Exited ExitCode
367 <Sect2 id="Process-Primitives">
368 <Title>Posix Process Primitives
374 forkProcess :: IO (Maybe ProcessID)
380 <Function>forkProcess</Function> calls <Function>fork</Function>, returning
381 <Literal>Just pid</Literal> to the parent, where <VarName>pid</VarName> is the
382 ProcessID of the child, and returning <Literal>Nothing</Literal> to the
389 executeFile :: FilePath -- Command
390 -> Bool -- Search PATH?
391 -> [String] -- Arguments
392 -> Maybe [(String, String)] -- Environment
399 <Literal>executeFile cmd args env</Literal> calls one of the
400 <Function>execv*</Function> family, depending on whether or not the current
401 PATH is to be searched for the command, and whether or not an
402 environment is provided to supersede the process's current
403 environment. The basename (leading directory names suppressed) of
404 the command is passed to <Function>execv*</Function> as <VarName>arg[0]</VarName>;
405 the argument list passed to <Function>executeFile</Function> therefore begins with <VarName>arg[1]</VarName>.
411 Search PATH? Supersede environ? Call
412 ~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ~~~~~~~
422 Note that <Function>execvpe</Function> is not provided by the POSIX standard, and must
423 be written by hand. Care must be taken to ensure that the search path
424 is extracted from the original environment, and not from the
425 environment to be passed on to the new image.
429 NOTE: In general, sharing open files between parent and child
430 processes is potential bug farm, and should be avoided unless you
431 really depend on this `feature' of POSIX' <Function>fork()</Function> semantics. Using
432 Haskell, there's the extra complication that arguments to
433 <Function>executeFile</Function> might come from files that are read lazily (using
434 <Function>hGetContents</Function>, or some such.) If this is the case, then for your own
435 sanity, please ensure that the arguments to <Function>executeFile</Function> have been
436 fully evaluated before calling <Function>forkProcess</Function> (followed by
437 <Function>executeFile</Function>.) Consider yourself warned :-)
441 A successful <Function>executeFile</Function> overlays the current process image with
442 a new one, so it only returns on failure.
448 runProcess :: FilePath -- Command
449 -> [String] -- Arguments
450 -> Maybe [(String, String)] -- Environment (Nothing -> Inherited)
451 -> Maybe FilePath -- Working directory (Nothing -> inherited)
452 -> Maybe Handle -- stdin (Nothing -> inherited)
453 -> Maybe Handle -- stdout (Nothing -> inherited)
454 -> Maybe Handle -- stderr (Nothing -> inherited)
461 <Function>runProcess</Function> is our candidate for the high-level OS-independent
466 <Literal>runProcess cmd args env wd inhdl outhdl errhdl</Literal> runs <Command>cmd</Command>
467 (searching the current <Literal>PATH</Literal>) with arguments <Literal>args</Literal>. If
468 <Literal>env</Literal> is <Literal>Just pairs</Literal>, the command is executed with the
469 environment specified by <Literal>pairs</Literal> of variables and values;
470 otherwise, the command is executed with the current environment. If
471 <Literal>wd</Literal> is <Literal>Just dir</Literal>, the command is executed with working
472 directory <Literal>dir</Literal>; otherwise, the command is executed in the current
473 working directory. If <Literal>{in,out,err</Literal>hdl} is <Literal>Just handle</Literal>, the
474 command is executed with the <Literal>Fd</Literal> for <Literal>std{in,out,err</Literal>}
475 attached to the specified <Literal>handle</Literal>; otherwise, the <Literal>Fd</Literal> for
476 <Literal>std{in,out,err</Literal>} is left unchanged.
482 getProcessStatus :: Bool -- Block?
483 -> Bool -- Stopped processes?
485 -> IO (Maybe ProcessStatus)
491 <Literal>getProcessStatus blk stopped pid</Literal> calls <Function>waitpid</Function>, returning
492 <Literal>Just tc</Literal>, the <Literal>ProcessStatus</Literal> for process <Literal>pid</Literal> if it is
493 available, <Literal>Nothing</Literal> otherwise. If <Literal>blk</Literal> is <Literal>False</Literal>, then
494 <Literal>WNOHANG</Literal> is set in the options for <Function>waitpid</Function>, otherwise not.
495 If <Literal>stopped</Literal> is <Literal>True</Literal>, then <Literal>WUNTRACED</Literal> is set in the
496 options for <Function>waitpid</Function>, otherwise not.
502 getGroupProcessStatus :: Bool -- Block?
503 -> Bool -- Stopped processes?
504 -> ProcessGroupID
505 -> IO (Maybe (ProcessID, ProcessStatus))
511 <Literal>getGroupProcessStatus blk stopped pgid</Literal> calls <Function>waitpid</Function>,
512 returning <Literal>Just (pid, tc)</Literal>, the <Literal>ProcessID</Literal> and
513 <Literal>ProcessStatus</Literal> for any process in group <Literal>pgid</Literal> if one is
514 available, <Literal>Nothing</Literal> otherwise. If <Literal>blk</Literal> is <Literal>False</Literal>, then
515 <Literal>WNOHANG</Literal> is set in the options for <Function>waitpid</Function>, otherwise not.
516 If <Literal>stopped</Literal> is <Literal>True</Literal>, then <Literal>WUNTRACED</Literal> is set in the
517 options for <Function>waitpid</Function>, otherwise not.
523 getAnyProcessStatus :: Bool -- Block?
524 -> Bool -- Stopped processes?
525 -> IO (Maybe (ProcessID, ProcessStatus))
531 <Literal>getAnyProcessStatus blk stopped</Literal> calls <Function>waitpid</Function>, returning
532 <Literal>Just (pid, tc)</Literal>, the <Literal>ProcessID</Literal> and <Literal>ProcessStatus</Literal> for any
533 child process if one is available, <Literal>Nothing</Literal> otherwise. If
534 <Literal>blk</Literal> is <Literal>False</Literal>, then <Literal>WNOHANG</Literal> is set in the options for
535 <Function>waitpid</Function>, otherwise not. If <Literal>stopped</Literal> is <Literal>True</Literal>, then
536 <Literal>WUNTRACED</Literal> is set in the options for <Function>waitpid</Function>, otherwise not.
542 exitImmediately :: ExitCode -> IO ()
548 <Literal>exitImmediately status</Literal> calls <Function>_exit</Function> to terminate the process
549 with the indicated exit <Literal>status</Literal>.
550 The operation never returns.
556 getEnvironment :: IO [(String, String)]
562 <Function>getEnvironment</Function> parses the environment variable mapping provided by
563 <Literal>environ</Literal>, returning <Literal>(variable, value)</Literal> pairs.
564 The operation never fails.
570 setEnvironment :: [(String, String)] -> IO ()
576 <Function>setEnvironment</Function> replaces the process environment with the provided
577 mapping of <Literal>(variable, value)</Literal> pairs.
583 getEnvVar :: String -> IO String
589 <Literal>getEnvVar var</Literal> returns the value associated with variable <VarName>var</VarName>
590 in the current environment (identical functionality provided through
591 standard Haskell library function <Function>System.getEnv</Function>).
595 The operation may fail with:
602 <Term><Literal>NoSuchThing</Literal></Term>
605 The variable has no mapping in the current environment.
615 setEnvVar :: String -> String -> IO ()
621 <Literal>setEnvVar var val</Literal> sets the value associated with variable <VarName>var</VarName>
622 in the current environment to be <Literal>val</Literal>. Any previous mapping is
629 removeEnvVar :: String -> IO ()
635 <Literal>removeEnvVar var</Literal> removes any value associated with variable <VarName>var</VarName>
636 in the current environment. Deleting a variable for which there is no mapping
637 does not generate an error.
646 backgroundRead, sigTTIN :: Signal
647 backgroundWrite, sigTTOU :: Signal
648 continueProcess, sigCONT :: Signal
649 floatingPointException, sigFPE :: Signal
650 illegalInstruction, sigILL :: Signal
651 internalAbort, sigABRT :: Signal
652 keyboardSignal, sigINT :: Signal
653 keyboardStop, sigTSTP :: Signal
654 keyboardTermination, sigQUIT :: Signal
655 killProcess, sigKILL :: Signal
656 lostConnection, sigHUP :: Signal
657 openEndedPipe, sigPIPE :: Signal
658 processStatusChanged, sigCHLD :: Signal
659 realTimeAlarm, sigALRM :: Signal
660 segmentationViolation, sigSEGV :: Signal
661 softwareStop, sigSTOP :: Signal
662 softwareTermination, sigTERM :: Signal
663 userDefinedSignal1, sigUSR1 :: Signal
664 userDefinedSignal2, sigUSR2 :: Signal
666 signalProcess :: Signal -> ProcessID -> IO ()
672 <Literal>signalProcess int pid</Literal> calls <Function>kill</Function> to signal
673 process <Literal>pid</Literal> with interrupt signal <Literal>int</Literal>.
679 raiseSignal :: Signal -> IO ()
685 <Literal>raiseSignal int</Literal> calls <Function>kill</Function> to signal the current process
686 with interrupt signal <Literal>int</Literal>.
692 signalProcessGroup :: Signal -> ProcessGroupID -> IO ()
698 <Literal>signalProcessGroup int pgid</Literal> calls <Function>kill</Function> to signal
699 all processes in group <Literal>pgid</Literal> with interrupt signal <Literal>int</Literal>.
705 setStoppedChildFlag :: Bool -> IO Bool
711 <Literal>setStoppedChildFlag bool</Literal> sets a flag which controls whether or
712 not the <Constant>NOCLDSTOP</Constant> option will be used the next time a signal
713 handler is installed for <Constant>SIGCHLD</Constant>. If <Literal>bool</Literal> is <Literal>True</Literal> (the
714 default), <Constant>NOCLDSTOP</Constant> will not be used; otherwise it will be. The
715 operation never fails.
721 queryStoppedChildFlag :: IO Bool
727 <Function>queryStoppedChildFlag</Function> queries the flag which
728 controls whether or not the <Constant>NOCLDSTOP</Constant> option will be used
729 the next time a signal handler is installed for <Constant>SIGCHLD</Constant>.
730 If <Constant>NOCLDSTOP</Constant> will be used, it returns <Literal>False</Literal>;
731 otherwise (the default) it returns <Literal>True</Literal>.
732 The operation never fails.
738 emptySignalSet :: SignalSet
739 fullSignalSet :: SignalSet
740 addSignal :: Signal -> SignalSet -> SignalSet
741 deleteSignal :: Signal -> SignalSet -> SignalSet
742 inSignalSet :: Signal -> SignalSet -> Bool
744 installHandler :: Signal
746 -> Maybe SignalSet -- other signals to block
747 -> IO Handler -- old handler
753 <Literal>installHandler int handler iset</Literal> calls <Constant>sigaction</Constant> to install an
754 interrupt handler for signal <Literal>int</Literal>. If <Literal>handler</Literal> is <Literal>Default</Literal>,
755 <Constant>SIG_DFL</Constant> is installed; if <Literal>handler</Literal> is <Literal>Ignore</Literal>, <Constant>SIG_IGN</Constant> is
756 installed; if <Literal>handler</Literal> is <Literal>Catch action</Literal>, a handler is installed
757 which will invoke <Literal>action</Literal> in a new thread when (or shortly after) the
758 signal is received. See <XRef LinkEnd="concurrent-haskell"> for details on how to communicate between
763 If <Literal>iset</Literal> is <Literal>Just s</Literal>, then the <VarName>sa_mask</VarName> of the <Literal>sigaction</Literal> structure
764 is set to <Literal>s</Literal>; otherwise it is cleared. The previously installed
765 signal handler for <Literal>int</Literal> is returned.
771 getSignalMask :: IO SignalSet
777 <Function>getSignalMask</Function> calls <Function>sigprocmask</Function> to determine the
778 set of interrupts which are currently being blocked.
784 setSignalMask :: SignalSet -> IO SignalSet
790 <Literal>setSignalMask mask</Literal> calls <Function>sigprocmask</Function> with
791 <Constant>SIG_SETMASK</Constant> to block all interrupts in <Literal>mask</Literal>. The
792 previous set of blocked interrupts is returned.
798 blockSignals :: SignalSet -> IO SignalSet
804 <Literal>setSignalMask mask</Literal> calls <Function>sigprocmask</Function> with
805 <Constant>SIG_BLOCK</Constant> to add all interrupts in <Literal>mask</Literal> to the
806 set of blocked interrupts. The previous set of blocked interrupts is returned.
812 unBlockSignals :: SignalSet -> IO SignalSet
818 <Literal>setSignalMask mask</Literal> calls <Function>sigprocmask</Function> with
819 <Constant>SIG_UNBLOCK</Constant> to remove all interrupts in <Literal>mask</Literal> from the
820 set of blocked interrupts. The previous set of blocked interrupts is returned.
826 getPendingSignals :: IO SignalSet
832 <Function>getPendingSignals</Function> calls <Function>sigpending</Function> to obtain
833 the set of interrupts which have been received but are currently blocked.
839 awaitSignal :: Maybe SignalSet -> IO ()
845 <Literal>awaitSignal iset</Literal> suspends execution until an interrupt is received.
846 If <Literal>iset</Literal> is <Literal>Just s</Literal>, <Function>awaitSignal</Function> calls <Function>sigsuspend</Function>, installing
847 <Literal>s</Literal> as the new signal mask before suspending execution; otherwise, it
848 calls <Function>pause</Function>. <Function>awaitSignal</Function> returns on receipt of a signal. If you
849 have installed any signal handlers with <Function>installHandler</Function>, it may be
850 wise to call <Function>yield</Function> directly after <Function>awaitSignal</Function> to ensure that the
851 signal handler runs as promptly.
857 scheduleAlarm :: Int -> IO Int
863 <Literal>scheduleAlarm i</Literal> calls <Function>alarm</Function> to schedule a real time
864 alarm at least <Literal>i</Literal> seconds in the future.
870 sleep :: Int -> IO ()
876 <Literal>sleep i</Literal> calls <Function>sleep</Function> to suspend execution of the
877 program until at least <Literal>i</Literal> seconds have elapsed or a signal is
883 <Sect2 id="Process-Environment">
884 <Title>Posix Process Environment
888 <IndexTerm><Primary>Posix, process environment</Primary></IndexTerm>
894 getProcessID :: IO ProcessID
900 <Function>getProcessID</Function> calls <Function>getpid</Function> to obtain the <Literal>ProcessID</Literal> for
907 getParentProcessID :: IO ProcessID
913 <Function>getProcessID</Function> calls <Function>getppid</Function> to obtain the <Literal>ProcessID</Literal> for
914 the parent of the current process.
920 getRealUserID :: IO UserID
926 <Function>getRealUserID</Function> calls <Function>getuid</Function> to obtain the real <Literal>UserID</Literal>
927 associated with the current process.
933 getEffectiveUserID :: IO UserID
939 <Function>getRealUserID</Function> calls <Function>geteuid</Function> to obtain the effective
940 <Literal>UserID</Literal> associated with the current process.
946 setUserID :: UserID -> IO ()
952 <Literal>setUserID uid</Literal> calls <Function>setuid</Function> to set the real, effective, and
953 saved set-user-id associated with the current process to <Literal>uid</Literal>.
959 getLoginName :: IO String
965 <Function>getLoginName</Function> calls <Function>getlogin</Function> to obtain the login name
966 associated with the current process.
972 getRealGroupID :: IO GroupID
978 <Function>getRealGroupID</Function> calls <Function>getgid</Function> to obtain the real <Literal>GroupID</Literal>
979 associated with the current process.
985 getEffectiveGroupID :: IO GroupID
991 <Function>getEffectiveGroupID</Function> calls <Function>getegid</Function> to obtain the effective
992 <Literal>GroupID</Literal> associated with the current process.
998 setGroupID :: GroupID -> IO ()
1004 <Literal>setGroupID gid</Literal> calls <Function>setgid</Function> to set the real, effective, and
1005 saved set-group-id associated with the current process to <Literal>gid</Literal>.
1011 getGroups :: IO [GroupID]
1017 <Function>getGroups</Function> calls <Function>getgroups</Function> to obtain the list of
1018 supplementary <Literal>GroupID</Literal>s associated with the current process.
1024 getEffectiveUserName :: IO String
1030 <Function>getEffectiveUserName</Function> calls <Function>cuserid</Function> to obtain a name
1031 associated with the effective <Literal>UserID</Literal> of the process.
1037 getProcessGroupID :: IO ProcessGroupID
1043 <Function>getProcessGroupID</Function> calls <Function>getpgrp</Function> to obtain the
1044 <Literal>ProcessGroupID</Literal> for the current process.
1050 createProcessGroup :: ProcessID -> IO ProcessGroupID
1056 <Literal>createProcessGroup pid</Literal> calls <Function>setpgid</Function> to make
1057 process <Literal>pid</Literal> a new process group leader.
1063 joinProcessGroup :: ProcessGroupID -> IO ProcessGroupID
1069 <Literal>joinProcessGroup pgid</Literal> calls <Function>setpgid</Function> to set the
1070 <Literal>ProcessGroupID</Literal> of the current process to <Literal>pgid</Literal>.
1076 setProcessGroupID :: ProcessID -> ProcessGroupID -> IO ()
1082 <Literal>setProcessGroupID pid pgid</Literal> calls <Function>setpgid</Function> to set the
1083 <Literal>ProcessGroupID</Literal> for process <Literal>pid</Literal> to <Literal>pgid</Literal>.
1089 createSession :: IO ProcessGroupID
1095 <Function>createSession</Function> calls <Function>setsid</Function> to create a new session
1096 with the current process as session leader.
1102 systemName :: SystemID -> String
1103 nodeName :: SystemID -> String
1104 release :: SystemID -> String
1105 version :: SystemID -> String
1106 machine :: SystemID -> String
1108 getSystemID :: IO SystemID
1114 <Function>getSystemID</Function> calls <Function>uname</Function> to obtain information
1115 about the current operating system.
1121 > epochTime :: IO EpochTime
1127 <Function>epochTime</Function> calls <Function>time</Function> to obtain the number of
1128 seconds that have elapsed since the epoch (Jan 01 00:00:00 GMT 1970).
1134 elapsedTime :: ProcessTimes -> ClockTick
1135 userTime :: ProcessTimes -> ClockTick
1136 systemTime :: ProcessTimes -> ClockTick
1137 childUserTime :: ProcessTimes -> ClockTick
1138 childSystemTime :: ProcessTimes -> ClockTick
1140 getProcessTimes :: IO ProcessTimes
1146 <Function>getProcessTimes</Function> calls <Function>times</Function> to obtain time-accounting
1147 information for the current process and its children.
1153 getControllingTerminalName :: IO FilePath
1159 <Function>getControllingTerminalName</Function> calls <Function>ctermid</Function> to obtain
1160 a name associated with the controlling terminal for the process. If a
1161 controlling terminal exists,
1162 <Function>getControllingTerminalName</Function> returns the name of the
1163 controlling terminal.
1167 The operation may fail with:
1174 <Term><Literal>NoSuchThing</Literal></Term>
1177 There is no controlling terminal, or its name cannot be determined.
1182 <Term><Literal>SystemError</Literal></Term>
1185 Various other causes.
1195 getTerminalName :: Fd -> IO FilePath
1201 <Literal>getTerminalName fd</Literal> calls <Function>ttyname</Function> to obtain a name associated
1202 with the terminal for <Literal>Fd</Literal> <Literal>fd</Literal>. If <Literal>fd</Literal> is associated
1203 with a terminal, <Function>getTerminalName</Function> returns the name of the
1208 The operation may fail with:
1215 <Term><Literal>InappropriateType</Literal></Term>
1218 The channel is not associated with a terminal.
1223 <Term><Literal>NoSuchThing</Literal></Term>
1226 The channel is associated with a terminal, but it has no name.
1231 <Term><Literal>SystemError</Literal></Term>
1234 Various other causes.
1244 queryTerminal :: Fd -> IO Bool
1250 <Literal>queryTerminal fd</Literal> calls <Function>isatty</Function> to determine whether or
1251 not <Literal>Fd</Literal> <Literal>fd</Literal> is associated with a terminal.
1257 getSysVar :: SysVar -> IO Limit
1263 <Literal>getSysVar var</Literal> calls <Function>sysconf</Function> to obtain the
1264 dynamic value of the requested configurable system limit or option.
1265 For defined system limits, <Function>getSysVar</Function> returns the associated
1266 value. For defined system options, the result of <Function>getSysVar</Function>
1267 is undefined, but not failure.
1271 The operation may fail with:
1278 <Term><Literal>NoSuchThing</Literal></Term>
1281 The requested system limit or option is undefined.
1290 <Sect2 id="Files-and-Directories">
1291 <Title>Posix operations on files and directories
1295 <IndexTerm><Primary>Posix, files and directories</Primary></IndexTerm>
1301 openDirStream :: FilePath -> IO DirStream
1307 <Literal>openDirStream dir</Literal> calls <Function>opendir</Function> to obtain a
1308 directory stream for <Literal>dir</Literal>.
1314 readDirStream :: DirStream -> IO String
1320 <Literal>readDirStream dp</Literal> calls <Function>readdir</Function> to obtain the
1321 next directory entry (<Literal>struct dirent</Literal>) for the open directory
1322 stream <Literal>dp</Literal>, and returns the <VarName>d_name</VarName> member of that
1327 The operation may fail with:
1334 <Term><Literal>EOF</Literal></Term>
1337 End of file has been reached.
1342 <Term><Literal>SystemError</Literal></Term>
1345 Various other causes.
1355 rewindDirStream :: DirStream -> IO ()
1361 <Literal>rewindDirStream dp</Literal> calls <Function>rewinddir</Function> to reposition
1362 the directory stream <Literal>dp</Literal> at the beginning of the directory.
1368 closeDirStream :: DirStream -> IO ()
1374 <Literal>closeDirStream dp</Literal> calls <Function>closedir</Function> to close
1375 the directory stream <Literal>dp</Literal>.
1381 getWorkingDirectory :: IO FilePath
1387 <Function>getWorkingDirectory</Function> calls <Function>getcwd</Function> to obtain the name
1388 of the current working directory.
1394 changeWorkingDirectory :: FilePath -> IO ()
1400 <Literal>changeWorkingDirectory dir</Literal> calls <Function>chdir</Function> to change
1401 the current working directory to <Literal>dir</Literal>.
1406 nullFileMode :: FileMode -- ---------
1407 ownerReadMode :: FileMode -- r--------
1408 ownerWriteMode :: FileMode -- -w-------
1409 ownerExecuteMode :: FileMode -- --x------
1410 groupReadMode :: FileMode -- ---r-----
1411 groupWriteMode :: FileMode -- ----w----
1412 groupExecuteMode :: FileMode -- -----x---
1413 otherReadMode :: FileMode -- ------r--
1414 otherWriteMode :: FileMode -- -------w-
1415 otherExecuteMode :: FileMode -- --------x
1416 setUserIDMode :: FileMode -- --S------
1417 setGroupIDMode :: FileMode -- -----S---
1419 stdFileMode :: FileMode -- rw-rw-rw-
1421 ownerModes :: FileMode -- rwx------
1422 groupModes :: FileMode -- ---rwx---
1423 otherModes :: FileMode -- ------rwx
1424 accessModes :: FileMode -- rwxrwxrwx
1426 unionFileModes :: FileMode -> FileMode -> FileMode
1427 intersectFileModes :: FileMode -> FileMode -> FileMode
1430 stdInput = intToFd 0
1433 stdOutput = intToFd 1
1436 stdError = intToFd 2
1438 data OpenFileFlags =
1449 -> Maybe FileMode -- Just x => O_CREAT, Nothing => must exist
1450 -> OpenFileFlags
1456 <Literal>openFd path acc mode (OpenFileFlags app excl noctty nonblock trunc)</Literal> calls
1457 <Function>open</Function> to obtain a <Literal>Fd</Literal> for the file <Literal>path</Literal> with access
1458 mode <Literal>acc</Literal>. If <Literal>mode</Literal> is <Literal>Just m</Literal>, the <Constant>O_CREAT</Constant> flag is
1459 set and the file's permissions will be based on <Literal>m</Literal> if it does not
1460 already exist; otherwise, the <Constant>O_CREAT</Constant> flag is not set. The
1461 arguments <Literal>app</Literal>, <Literal>excl</Literal>, <Literal>noctty</Literal>, <Literal>nonblock</Literal>, and
1462 <Literal>trunc</Literal> control whether or not the flags <Constant>O_APPEND</Constant>,
1463 <Constant>O_EXCL</Constant>, <Constant>O_NOCTTY</Constant>, <Constant>O_NONBLOCK</Constant>, and <Constant>O_TRUNC</Constant> are set,
1470 createFile :: FilePath -> FileMode -> IO Fd
1476 <Literal>createFile path mode</Literal> calls <Function>creat</Function> to obtain a <Literal>Fd</Literal>
1477 for file <Literal>path</Literal>, which will be created with permissions based on
1478 <Literal>mode</Literal> if it does not already exist.
1484 setFileCreationMask :: FileMode -> IO FileMode
1490 <Literal>setFileCreationMask mode</Literal> calls <Function>umask</Function> to set
1491 the process's file creation mask to <Literal>mode</Literal>. The previous file
1492 creation mask is returned.
1498 createLink :: FilePath -> FilePath -> IO ()
1504 <Literal>createLink old new</Literal> calls <Function>link</Function> to create a
1505 new path, <Literal>new</Literal>, linked to an existing file, <Literal>old</Literal>.
1508 createDirectory :: FilePath -> FileMode -> IO ()
1514 <Literal>createDirectory dir mode</Literal> calls <Function>mkdir</Function> to
1515 create a new directory, <Literal>dir</Literal>, with permissions based on
1516 <Literal>mode</Literal>.
1522 createNamedPipe :: FilePath -> FileMode -> IO ()
1528 <Literal>createNamedPipe fifo mode</Literal> calls <Function>mkfifo</Function> to
1529 create a new named pipe, <Literal>fifo</Literal>, with permissions based on
1530 <Literal>mode</Literal>.
1536 removeLink :: FilePath -> IO ()
1542 <Literal>removeLink path</Literal> calls <Function>unlink</Function> to remove the link
1543 named <Literal>path</Literal>.
1549 removeDirectory :: FilePath -> IO ()
1555 <Literal>removeDirectory dir</Literal> calls <Function>rmdir</Function> to remove the
1556 directory named <Literal>dir</Literal>.
1562 rename :: FilePath -> FilePath -> IO ()
1568 <Literal>rename old new</Literal> calls <Function>rename</Function> to rename a
1569 file or directory from <Literal>old</Literal> to <Literal>new</Literal>.
1575 fileMode :: FileStatus -> FileMode
1577 fileID :: FileStatus -> FileID
1578 deviceID :: FileStatus -> DeviceID
1580 linkCount :: FileStatus -> LinkCount
1582 fileOwner :: FileStatus -> UserID
1583 fileGroup :: FileStatus -> GroupID
1584 fileSize :: FileStatus -> FileOffset
1586 accessTime :: FileStatus -> EpochTime
1587 modificationTime :: FileStatus -> EpochTime
1588 statusChangeTime :: FileStatus -> EpochTime
1590 isDirectory :: FileStatus -> Bool
1591 isCharacterDevice :: FileStatus -> Bool
1592 isBlockDevice :: FileStatus -> Bool
1593 isRegularFile :: FileStatus -> Bool
1594 isNamedPipe :: FileStatus -> Bool
1596 getFileStatus :: FilePath -> IO FileStatus
1602 <Literal>getFileStatus path</Literal> calls <Function>stat</Function> to get the
1603 <Literal>FileStatus</Literal> information for the file <Literal>path</Literal>.
1609 getFdStatus :: Fd -> IO FileStatus
1615 <Literal>getFdStatus fd</Literal> calls <Function>fstat</Function> to get the
1616 <Literal>FileStatus</Literal> information for the file associated with
1617 <Literal>Fd</Literal> <Literal>fd</Literal>.
1623 queryAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool
1629 <Literal>queryAccess path r w x</Literal> calls <Function>access</Function> to test the access
1630 permissions for file <Literal>path</Literal>. The three arguments, <Literal>r</Literal>, <Literal>w</Literal>,
1631 and <Literal>x</Literal> control whether or not <Function>access</Function> is called with
1632 <Constant>R_OK</Constant>, <Constant>W_OK</Constant>, and <Constant>X_OK</Constant> respectively.
1638 queryFile :: FilePath -> IO Bool
1644 <Literal>queryFile path</Literal> calls <Function>access</Function> with <Constant>F_OK</Constant> to test for the
1645 existence for file <Literal>path</Literal>.
1651 setFileMode :: FilePath -> FileMode -> IO ()
1657 <Literal>setFileMode path mode</Literal> calls <Function>chmod</Function> to set the
1658 permission bits associated with file <Literal>path</Literal> to <Literal>mode</Literal>.
1664 setOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()
1670 <Literal>setOwnerAndGroup path uid gid</Literal> calls <Function>chown</Function> to
1671 set the <Literal>UserID</Literal> and <Literal>GroupID</Literal> associated with file
1672 <Literal>path</Literal> to <Literal>uid</Literal> and <Literal>gid</Literal>, respectively.
1678 setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO ()
1684 <Literal>setFileTimes path atime mtime</Literal> calls <Function>utime</Function> to
1685 set the access and modification times associated with file
1686 <Literal>path</Literal> to <Literal>atime</Literal> and <Literal>mtime</Literal>, respectively.
1692 touchFile :: FilePath -> IO ()
1698 <Literal>touchFile path</Literal> calls <Function>utime</Function> to
1699 set the access and modification times associated with file
1700 <Literal>path</Literal> to the current time.
1706 getPathVar :: PathVar -> FilePath -> IO Limit
1712 <Literal>getPathVar var path</Literal> calls <Function>pathconf</Function> to obtain the
1713 dynamic value of the requested configurable file limit or option associated
1714 with file or directory <Literal>path</Literal>. For
1715 defined file limits, <Function>getPathVar</Function> returns the associated
1716 value. For defined file options, the result of <Function>getPathVar</Function>
1717 is undefined, but not failure.
1718 The operation may fail with:
1722 <Term><Literal>NoSuchThing</Literal></Term>
1725 The requested file limit or option is undefined.
1730 <Term><Literal>SystemError</Literal></Term>
1733 Various other causes.
1743 getFdVar :: PathVar -> Fd -> IO Limit
1749 <Literal>getFdVar var fd</Literal> calls <Function>fpathconf</Function> to obtain the
1750 dynamic value of the requested configurable file limit or option associated
1751 with the file or directory attached to the open channel <Literal>fd</Literal>.
1752 For defined file limits, <Function>getFdVar</Function> returns the associated
1753 value. For defined file options, the result of <Function>getFdVar</Function>
1754 is undefined, but not failure.
1758 The operation may fail with:
1765 <Term><Literal>NoSuchThing</Literal></Term>
1768 The requested file limit or option is undefined.
1773 <Term><Literal>SystemError</Literal></Term>
1776 Various other causes.
1785 <Sect2 id="Input-Output">
1786 <Title>Posix Input and Output Primitives
1790 <IndexTerm><Primary>Posix, input/output</Primary></IndexTerm>
1796 createPipe :: IO (Fd, Fd)
1802 <Function>createPipe</Function> calls <Function>pipe</Function> to create a pipe and returns a pair of
1803 <Literal>Fd</Literal>s, the first for reading and the second for writing.
1809 dup :: Fd -> IO Fd
1815 <Literal>dup fd</Literal> calls <Function>dup</Function> to duplicate <Literal>Fd</Literal> <Literal>fd</Literal> to
1816 another <Literal>Fd</Literal>.
1822 dupTo :: Fd -> Fd -> IO ()
1828 <Literal>dupTo src dst</Literal> calls <Function>dup2</Function> to duplicate <Literal>Fd</Literal>
1829 <Literal>src</Literal> to <Literal>Fd</Literal> <Literal>dst</Literal>.
1835 fdClose :: Fd -> IO ()
1841 <Literal>fdClose fd</Literal> calls <Function>close</Function> to close <Literal>Fd</Literal> <Literal>fd</Literal>.
1847 fdRead :: Fd -> ByteCount -> IO (String, ByteCount)
1853 <Literal>fdRead fd nbytes</Literal> calls <Function>read</Function> to read at most <Literal>nbytes</Literal>
1854 bytes from <Literal>Fd</Literal> <Literal>fd</Literal>, and returns the result as a string
1855 paired with the number of bytes actually read.
1859 The operation may fail with:
1866 <Term><Literal>EOF</Literal></Term>
1869 End of file has been reached.
1874 <Term><Literal>SystemError</Literal></Term>
1877 Various other causes.
1887 fdWrite :: Fd -> String -> IO ByteCount
1893 <Literal>fdWrite fd s</Literal> calls <Function>write</Function> to write
1894 the string <Literal>s</Literal> to <Literal>Fd</Literal> <Literal>fd</Literal> as a
1895 contiguous sequence of bytes. It returns the number of bytes successfully
1902 queryFdOption :: FdOption -> Fd -> IO Bool
1908 <Literal>getFdOption opt fd</Literal> calls <Function>fcntl</Function> to determine whether or
1909 not the flag associated with <Literal>FdOption</Literal> <Literal>opt</Literal> is set for
1910 <Literal>Fd</Literal> <Literal>fd</Literal>.
1916 setFdOption :: Fd -> FdOption -> Bool -> IO ()
1922 <Literal>setFdOption fd opt val</Literal> calls <Function>fcntl</Function> to set the flag
1923 associated with <Literal>FdOption</Literal> <Literal>opt</Literal> on <Literal>Fd</Literal> <Literal>fd</Literal> to
1924 <Literal>val</Literal>.
1930 getLock :: Fd -> FileLock -> IO (Maybe (ProcessID, FileLock))
1936 <Literal>getLock fd lock</Literal> calls <Function>fcntl</Function> to get the first <Literal>FileLock</Literal>
1937 for <Literal>Fd</Literal> <Literal>fd</Literal> which blocks the <Literal>FileLock</Literal> <Literal>lock</Literal>. If
1938 no such <Literal>FileLock</Literal> exists, <Function>getLock</Function> returns <Literal>Nothing</Literal>.
1939 Otherwise, it returns <Literal>Just (pid, block)</Literal>, where <Literal>block</Literal> is the
1940 blocking <Literal>FileLock</Literal> and <Literal>pid</Literal> is the <Literal>ProcessID</Literal> of the
1941 process holding the blocking <Literal>FileLock</Literal>.
1947 setLock :: Fd -> FileLock -> IO ()
1953 <Literal>setLock fd lock</Literal> calls <Function>fcntl</Function> with <Constant>F_SETLK</Constant> to set or
1954 clear a lock segment for <Literal>Fd</Literal> <Literal>fd</Literal> as indicated by the
1955 <Literal>FileLock</Literal> <Literal>lock</Literal>. <Function>setLock</Function> does not block, but fails with
1956 <Literal>SystemError</Literal> if the request cannot be satisfied immediately.
1962 waitToSetLock :: Fd -> FileLock -> IO ()
1968 <Literal>waitToSetLock fd lock</Literal> calls <Function>fcntl</Function> with <Constant>F_SETLKW</Constant> to set
1969 or clear a lock segment for <Literal>Fd</Literal> <Literal>fd</Literal> as indicated by the
1970 <Literal>FileLock</Literal> <Literal>lock</Literal>. If the request cannot be satisfied
1971 immediately, <Function>waitToSetLock</Function> blocks until the request can be
1978 fdSeek :: Fd -> SeekMode -> FileOffset -> IO FileOffset
1984 <Literal>fdSeek fd whence offset</Literal> calls <Function>lseek</Function> to position the
1985 <Literal>Fd</Literal> <Literal>fd</Literal> at the given <Literal>offset</Literal> from the starting location
1986 indicated by <Literal>whence</Literal>. It returns the resulting offset from the
1987 start of the file in bytes.
1992 <Sect2 id="Device-Specific-Functions">
1993 <Title>Posix, Device- and Class-Specific Functions
1997 <IndexTerm><Primary>Posix, device and class-specific functions</Primary></IndexTerm>
2003 terminalMode :: TerminalMode -> TerminalAttributes -> Bool
2004 withMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
2005 withoutMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
2007 bitsPerByte :: TerminalAttributes -> Int
2008 withBits :: TerminalAttributes -> Int -> TerminalAttributes
2010 controlChar :: TerminalAttributes -> ControlCharacter -> Maybe Char
2011 withCC :: TerminalAttributes
2012 -> (ControlCharacter, Char)
2013 -> TerminalAttributes
2014 withoutCC :: TerminalAttributes
2015 -> ControlCharacter
2016 -> TerminalAttributes
2018 inputTime :: TerminalAttributes -> Int
2019 withTime :: TerminalAttributes -> Int -> TerminalAttributes
2021 minInput :: TerminalAttributes -> Int
2022 withMinInput :: TerminalAttributes -> Int -> TerminalAttributes
2024 inputSpeed :: TerminalAttributes -> BaudRate
2025 withInputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes
2027 outputSpeed :: TerminalAttributes -> BaudRate
2028 withOutputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes
2030 getTerminalAttributes :: Fd -> IO TerminalAttributes
2036 <Literal>getTerminalAttributes fd</Literal> calls <Function>tcgetattr</Function> to obtain
2037 the <Literal>TerminalAttributes</Literal> associated with <Literal>Fd</Literal> <Literal>fd</Literal>.
2043 setTerminalAttributes :: Fd
2044 -> TerminalAttributes
2045 -> TerminalState
2052 <Literal>setTerminalAttributes fd attr ts</Literal> calls <Function>tcsetattr</Function> to change
2053 the <Literal>TerminalAttributes</Literal> associated with <Literal>Fd</Literal> <Literal>fd</Literal> to
2054 <Literal>attr</Literal>, when the terminal is in the state indicated by <Literal>ts</Literal>.
2060 sendBreak :: Fd -> Int -> IO ()
2066 <Literal>sendBreak fd duration</Literal> calls <Function>tcsendbreak</Function> to transmit a
2067 continuous stream of zero-valued bits on <Literal>Fd</Literal> <Literal>fd</Literal> for the
2068 specified implementation-dependent <Literal>duration</Literal>.
2074 drainOutput :: Fd -> IO ()
2080 <Literal>drainOutput fd</Literal> calls <Function>tcdrain</Function> to block until all output
2081 written to <Literal>Fd</Literal> <Literal>fd</Literal> has been transmitted.
2087 discardData :: Fd -> QueueSelector -> IO ()
2093 <Literal>discardData fd queues</Literal> calls <Function>tcflush</Function> to discard
2094 pending input and/or output for <Literal>Fd</Literal> <Literal>fd</Literal>,
2095 as indicated by the <Literal>QueueSelector</Literal> <Literal>queues</Literal>.
2101 controlFlow :: Fd -> FlowAction -> IO ()
2107 <Literal>controlFlow fd action</Literal> calls <Function>tcflow</Function> to control the
2108 flow of data on <Literal>Fd</Literal> <Literal>fd</Literal>, as indicated by
2109 <Literal>action</Literal>.
2115 getTerminalProcessGroupID :: Fd -> IO ProcessGroupID
2121 <Literal>getTerminalProcessGroupID fd</Literal> calls <Function>tcgetpgrp</Function> to
2122 obtain the <Literal>ProcessGroupID</Literal> of the foreground process group
2123 associated with the terminal attached to <Literal>Fd</Literal> <Literal>fd</Literal>.
2129 setTerminalProcessGroupID :: Fd -> ProcessGroupID -> IO ()
2135 <Literal>setTerminalProcessGroupID fd pgid</Literal> calls <Function>tcsetpgrp</Function> to
2136 set the <Literal>ProcessGroupID</Literal> of the foreground process group
2137 associated with the terminal attached to <Literal>Fd</Literal>
2138 <Literal>fd</Literal> to <Literal>pgid</Literal>.
2143 <Sect2 id="System-Database">
2144 <Title>Posix System Databases
2148 <IndexTerm><Primary>Posix, system databases</Primary></IndexTerm>
2154 groupName :: GroupEntry -> String
2155 groupID :: GroupEntry -> GroupID
2156 groupMembers :: GroupEntry -> [String]
2158 getGroupEntryForID :: GroupID -> IO GroupEntry
2164 <Literal>getGroupEntryForID gid</Literal> calls <Function>getgrgid</Function> to obtain
2165 the <Literal>GroupEntry</Literal> information associated with <Literal>GroupID</Literal>
2166 <Literal>gid</Literal>.
2170 The operation may fail with:
2177 <Term><Literal>NoSuchThing</Literal></Term>
2180 There is no group entry for the GroupID.
2190 getGroupEntryForName :: String -> IO GroupEntry
2196 <Literal>getGroupEntryForName name</Literal> calls <Function>getgrnam</Function> to obtain
2197 the <Literal>GroupEntry</Literal> information associated with the group called
2198 <Literal>name</Literal>.
2202 The operation may fail with:
2209 <Term><Literal>NoSuchThing</Literal></Term>
2212 There is no group entry for the name.
2222 userName :: UserEntry -> String
2223 userID :: UserEntry -> UserID
2224 userGroupID :: UserEntry -> GroupID
2225 homeDirectory :: UserEntry -> String
2226 userShell :: UserEntry -> String
2228 getUserEntryForID :: UserID -> IO UserEntry
2234 <Literal>getUserEntryForID gid</Literal> calls <Function>getpwuid</Function> to obtain
2235 the <Literal>UserEntry</Literal> information associated with <Literal>UserID</Literal>
2236 <Literal>uid</Literal>.
2237 The operation may fail with:
2244 <Term><Literal>NoSuchThing</Literal></Term>
2247 There is no user entry for the UserID.
2257 getUserEntryForName :: String -> IO UserEntry
2263 <Literal>getUserEntryForName name</Literal> calls <Function>getpwnam</Function> to obtain
2264 the <Literal>UserEntry</Literal> information associated with the user login
2265 <Literal>name</Literal>.
2269 The operation may fail with:
2276 <Term><Literal>NoSuchThing</Literal></Term>
2279 There is no user entry for the name.
2288 <Sect2 id="Error-reporting-and-handling">
2293 <IndexTerm><Primary>Posix, errors</Primary></IndexTerm>
2299 getErrorCode :: IO ErrorCode
2305 <Function>getErrorCode</Function> returns the current value of the external
2306 variable <Function>errno</Function>. It never fails.
2312 setErrorCode :: ErrorCode -> IO ()
2318 <Literal>setErrorCode err</Literal> sets the external
2319 variable <Function>errno</Function> to <Literal>err</Literal>. It never fails.
2325 noError :: ErrorCode
2328 argumentListTooLong, e2BIG :: ErrorCode
2329 badFd, eBADF :: ErrorCode
2330 brokenPipe, ePIPE :: ErrorCode
2331 directoryNotEmpty, eNOTEMPTY :: ErrorCode
2332 execFormatError, eNOEXEC :: ErrorCode
2333 fileAlreadyExists, eEXIST :: ErrorCode
2334 fileTooLarge, eFBIG :: ErrorCode
2335 filenameTooLong, eNAMETOOLONG :: ErrorCode
2336 improperLink, eXDEV :: ErrorCode
2337 inappropriateIOControlOperation, eNOTTY :: ErrorCode
2338 inputOutputError, eIO :: ErrorCode
2339 interruptedOperation, eINTR :: ErrorCode
2340 invalidArgument, eINVAL :: ErrorCode
2341 invalidSeek, eSPIPE :: ErrorCode
2342 isADirectory, eISDIR :: ErrorCode
2343 noChildProcess, eCHILD :: ErrorCode
2344 noLocksAvailable, eNOLCK :: ErrorCode
2345 noSpaceLeftOnDevice, eNOSPC :: ErrorCode
2346 noSuchOperationOnDevice, eNODEV :: ErrorCode
2347 noSuchDeviceOrAddress, eNXIO :: ErrorCode
2348 noSuchFileOrDirectory, eNOENT :: ErrorCode
2349 noSuchProcess, eSRCH :: ErrorCode
2350 notADirectory, eNOTDIR :: ErrorCode
2351 notEnoughMemory, eNOMEM :: ErrorCode
2352 operationNotImplemented, eNOSYS :: ErrorCode
2353 operationNotPermitted, ePERM :: ErrorCode
2354 permissionDenied, eACCES :: ErrorCode
2355 readOnlyFileSystem, eROFS :: ErrorCode
2356 resourceBusy, eBUSY :: ErrorCode
2357 resourceDeadlockAvoided, eDEADLK :: ErrorCode
2358 resourceTemporarilyUnavailable, eAGAIN :: ErrorCode
2359 tooManyLinks, eMLINK :: ErrorCode
2360 tooManyOpenFiles, eMFILE :: ErrorCode
2361 tooManyOpenFilesInSystem, eNFILE :: ErrorCode