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 <Literal>-syslib posix</Literal> 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 <Literal>forkProcess</Literal> calls <Literal>fork</Literal>, returning
381 <Literal>Just pid</Literal> to the parent, where <Literal>pid</Literal> 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 <Literal>execv*</Literal> 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 <Literal>execv*</Literal> as <Literal>arg[0]</Literal>;
405 the argument list passed to <Literal>executeFile</Literal> therefore begins
406 with <Literal>arg[1]</Literal>.
412 Search PATH? Supersede environ? Call
413 ~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~ ~~~~~~~
423 Note that <Literal>execvpe</Literal> is not provided by the POSIX standard, and must
424 be written by hand. Care must be taken to ensure that the search path
425 is extracted from the original environment, and not from the
426 environment to be passed on to the new image.
430 NOTE: In general, sharing open files between parent and child
431 processes is potential bug farm, and should be avoided unless you
432 really depend on this `feature' of POSIX' <Literal>fork()</Literal> semantics. Using
433 Haskell, there's the extra complication that arguments to
434 <Literal>executeFile</Literal> might come from files that are read lazily (using
435 <Literal>hGetContents</Literal>, or some such.) If this is the case, then for your own
436 sanity, please ensure that the arguments to <Literal>executeFile</Literal> have been
437 fully evaluated before calling <Literal>forkProcess</Literal> (followed by
438 <Literal>executeFile</Literal>.) Consider yourself warned :-)
442 A successful <Literal>executeFile</Literal> overlays the current process image with
443 a new one, so it only returns on failure.
449 runProcess :: FilePath -- Command
450 -> [String] -- Arguments
451 -> Maybe [(String, String)] -- Environment (Nothing -> Inherited)
452 -> Maybe FilePath -- Working directory (Nothing -> inherited)
453 -> Maybe Handle -- stdin (Nothing -> inherited)
454 -> Maybe Handle -- stdout (Nothing -> inherited)
455 -> Maybe Handle -- stderr (Nothing -> inherited)
462 <Literal>runProcess</Literal> is our candidate for the high-level OS-independent
467 <Literal>runProcess cmd args env wd inhdl outhdl errhdl</Literal> runs <Literal>cmd</Literal>
468 (searching the current <Literal>PATH</Literal>) with arguments <Literal>args</Literal>. If
469 <Literal>env</Literal> is <Literal>Just pairs</Literal>, the command is executed with the
470 environment specified by <Literal>pairs</Literal> of variables and values;
471 otherwise, the command is executed with the current environment. If
472 <Literal>wd</Literal> is <Literal>Just dir</Literal>, the command is executed with working
473 directory <Literal>dir</Literal>; otherwise, the command is executed in the current
474 working directory. If <Literal>{in,out,err</Literal>hdl} is <Literal>Just handle</Literal>, the
475 command is executed with the <Literal>Fd</Literal> for <Literal>std{in,out,err</Literal>}
476 attached to the specified <Literal>handle</Literal>; otherwise, the <Literal>Fd</Literal> for
477 <Literal>std{in,out,err</Literal>} is left unchanged.
483 getProcessStatus :: Bool -- Block?
484 -> Bool -- Stopped processes?
486 -> IO (Maybe ProcessStatus)
492 <Literal>getProcessStatus blk stopped pid</Literal> calls <Literal>waitpid</Literal>, returning
493 <Literal>Just tc</Literal>, the <Literal>ProcessStatus</Literal> for process <Literal>pid</Literal> if it is
494 available, <Literal>Nothing</Literal> otherwise. If <Literal>blk</Literal> is <Literal>False</Literal>, then
495 <Literal>WNOHANG</Literal> is set in the options for <Literal>waitpid</Literal>, otherwise not.
496 If <Literal>stopped</Literal> is <Literal>True</Literal>, then <Literal>WUNTRACED</Literal> is set in the
497 options for <Literal>waitpid</Literal>, otherwise not.
503 getGroupProcessStatus :: Bool -- Block?
504 -> Bool -- Stopped processes?
505 -> ProcessGroupID
506 -> IO (Maybe (ProcessID, ProcessStatus))
512 <Literal>getGroupProcessStatus blk stopped pgid</Literal> calls <Literal>waitpid</Literal>,
513 returning <Literal>Just (pid, tc)</Literal>, the <Literal>ProcessID</Literal> and
514 <Literal>ProcessStatus</Literal> for any process in group <Literal>pgid</Literal> if one is
515 available, <Literal>Nothing</Literal> otherwise. If <Literal>blk</Literal> is <Literal>False</Literal>, then
516 <Literal>WNOHANG</Literal> is set in the options for <Literal>waitpid</Literal>, otherwise not.
517 If <Literal>stopped</Literal> is <Literal>True</Literal>, then <Literal>WUNTRACED</Literal> is set in the
518 options for <Literal>waitpid</Literal>, otherwise not.
524 getAnyProcessStatus :: Bool -- Block?
525 -> Bool -- Stopped processes?
526 -> IO (Maybe (ProcessID, ProcessStatus))
532 <Literal>getAnyProcessStatus blk stopped</Literal> calls <Literal>waitpid</Literal>, returning
533 <Literal>Just (pid, tc)</Literal>, the <Literal>ProcessID</Literal> and <Literal>ProcessStatus</Literal> for any
534 child process if one is available, <Literal>Nothing</Literal> otherwise. If
535 <Literal>blk</Literal> is <Literal>False</Literal>, then <Literal>WNOHANG</Literal> is set in the options for
536 <Literal>waitpid</Literal>, otherwise not. If <Literal>stopped</Literal> is <Literal>True</Literal>, then
537 <Literal>WUNTRACED</Literal> is set in the options for <Literal>waitpid</Literal>, otherwise not.
543 exitImmediately :: ExitCode -> IO ()
549 <Literal>exitImmediately status</Literal> calls <Literal>_exit</Literal> to terminate the process
550 with the indicated exit <Literal>status</Literal>.
551 The operation never returns.
557 getEnvironment :: IO [(String, String)]
563 <Literal>getEnvironment</Literal> parses the environment variable mapping provided by
564 <Literal>environ</Literal>, returning <Literal>(variable, value)</Literal> pairs.
565 The operation never fails.
571 setEnvironment :: [(String, String)] -> IO ()
577 <Literal>setEnvironment</Literal> replaces the process environment with the provided
578 mapping of <Literal>(variable, value)</Literal> pairs.
584 getEnvVar :: String -> IO String
590 <Literal>getEnvVar var</Literal> returns the value associated with variable <Literal>var</Literal>
591 in the current environment (identical functionality provided through
592 standard Haskell library function <Literal>System.getEnv</Literal>).
596 The operation may fail with:
603 <Term><Literal>NoSuchThing</Literal></Term>
606 The variable has no mapping in the current environment.
616 setEnvVar :: String -> String -> IO ()
622 <Literal>setEnvVar var val</Literal> sets the value associated with variable <Literal>var</Literal>
623 in the current environment to be <Literal>val</Literal>. Any previous mapping is
630 removeEnvVar :: String -> IO ()
636 <Literal>removeEnvVar var</Literal> removes any value associated with variable <Literal>var</Literal>
637 in the current environment. Deleting a variable for which there is no mapping
638 does not generate an error.
647 backgroundRead, sigTTIN :: Signal
648 backgroundWrite, sigTTOU :: Signal
649 continueProcess, sigCONT :: Signal
650 floatingPointException, sigFPE :: Signal
651 illegalInstruction, sigILL :: Signal
652 internalAbort, sigABRT :: Signal
653 keyboardSignal, sigINT :: Signal
654 keyboardStop, sigTSTP :: Signal
655 keyboardTermination, sigQUIT :: Signal
656 killProcess, sigKILL :: Signal
657 lostConnection, sigHUP :: Signal
658 openEndedPipe, sigPIPE :: Signal
659 processStatusChanged, sigCHLD :: Signal
660 realTimeAlarm, sigALRM :: Signal
661 segmentationViolation, sigSEGV :: Signal
662 softwareStop, sigSTOP :: Signal
663 softwareTermination, sigTERM :: Signal
664 userDefinedSignal1, sigUSR1 :: Signal
665 userDefinedSignal2, sigUSR2 :: Signal
667 signalProcess :: Signal -> ProcessID -> IO ()
673 <Literal>signalProcess int pid</Literal> calls <Literal>kill</Literal> to signal
674 process <Literal>pid</Literal> with interrupt signal <Literal>int</Literal>.
680 raiseSignal :: Signal -> IO ()
686 <Literal>raiseSignal int</Literal> calls <Literal>kill</Literal> to signal the current process
687 with interrupt signal <Literal>int</Literal>.
693 signalProcessGroup :: Signal -> ProcessGroupID -> IO ()
699 <Literal>signalProcessGroup int pgid</Literal> calls <Literal>kill</Literal> to signal
700 all processes in group <Literal>pgid</Literal> with interrupt signal <Literal>int</Literal>.
706 setStoppedChildFlag :: Bool -> IO Bool
712 <Literal>setStoppedChildFlag bool</Literal> sets a flag which controls whether or
713 not the <Literal>NOCLDSTOP</Literal> option will be used the next time a signal
714 handler is installed for <Literal>SIGCHLD</Literal>. If <Literal>bool</Literal> is <Literal>True</Literal> (the
715 default), <Literal>NOCLDSTOP</Literal> will not be used; otherwise it will be. The
716 operation never fails.
722 queryStoppedChildFlag :: IO Bool
728 <Literal>queryStoppedChildFlag</Literal> queries the flag which
729 controls whether or not the <Literal>NOCLDSTOP</Literal> option will be used
730 the next time a signal handler is installed for <Literal>SIGCHLD</Literal>.
731 If <Literal>NOCLDSTOP</Literal> will be used, it returns <Literal>False</Literal>;
732 otherwise (the default) it returns <Literal>True</Literal>.
733 The operation never fails.
739 emptySignalSet :: SignalSet
740 fullSignalSet :: SignalSet
741 addSignal :: Signal -> SignalSet -> SignalSet
742 deleteSignal :: Signal -> SignalSet -> SignalSet
743 inSignalSet :: Signal -> SignalSet -> Bool
745 installHandler :: Signal
747 -> Maybe SignalSet -- other signals to block
748 -> IO Handler -- old handler
754 <Literal>installHandler int handler iset</Literal> calls <Literal>sigaction</Literal> to install an
755 interrupt handler for signal <Literal>int</Literal>. If <Literal>handler</Literal> is <Literal>Default</Literal>,
756 <Literal>SIG_DFL</Literal> is installed; if <Literal>handler</Literal> is <Literal>Ignore</Literal>, <Literal>SIG_IGN</Literal> is
757 installed; if <Literal>handler</Literal> is <Literal>Catch action</Literal>, a handler is installed
758 which will invoke <Literal>action</Literal> in a new thread when (or shortly after) the
759 signal is received. See <XRef LinkEnd="concurrent-haskell"> for details on how to communicate between
764 If <Literal>iset</Literal> is <Literal>Just s</Literal>, then the <Literal>sa_mask</Literal> of the <Literal>sigaction</Literal> structure
765 is set to <Literal>s</Literal>; otherwise it is cleared. The previously installed
766 signal handler for <Literal>int</Literal> is returned.
772 getSignalMask :: IO SignalSet
778 <Literal>getSignalMask</Literal> calls <Literal>sigprocmask</Literal> to determine the
779 set of interrupts which are currently being blocked.
785 setSignalMask :: SignalSet -> IO SignalSet
791 <Literal>setSignalMask mask</Literal> calls <Literal>sigprocmask</Literal> with
792 <Literal>SIG_SETMASK</Literal> to block all interrupts in <Literal>mask</Literal>. The
793 previous set of blocked interrupts is returned.
799 blockSignals :: SignalSet -> IO SignalSet
805 <Literal>setSignalMask mask</Literal> calls <Literal>sigprocmask</Literal> with
806 <Literal>SIG_BLOCK</Literal> to add all interrupts in <Literal>mask</Literal> to the
807 set of blocked interrupts. The previous set of blocked interrupts is returned.
813 unBlockSignals :: SignalSet -> IO SignalSet
819 <Literal>setSignalMask mask</Literal> calls <Literal>sigprocmask</Literal> with
820 <Literal>SIG_UNBLOCK</Literal> to remove all interrupts in <Literal>mask</Literal> from the
821 set of blocked interrupts. The previous set of blocked interrupts is returned.
827 getPendingSignals :: IO SignalSet
833 <Literal>getPendingSignals</Literal> calls <Literal>sigpending</Literal> to obtain
834 the set of interrupts which have been received but are currently blocked.
840 awaitSignal :: Maybe SignalSet -> IO ()
846 <Literal>awaitSignal iset</Literal> suspends execution until an interrupt is received.
847 If <Literal>iset</Literal> is <Literal>Just s</Literal>, <Literal>awaitSignal</Literal> calls <Literal>sigsuspend</Literal>, installing
848 <Literal>s</Literal> as the new signal mask before suspending execution; otherwise, it
849 calls <Literal>pause</Literal>. <Literal>awaitSignal</Literal> returns on receipt of a signal. If you
850 have installed any signal handlers with <Literal>installHandler</Literal>, it may be
851 wise to call <Literal>yield</Literal> directly after <Literal>awaitSignal</Literal> to ensure that the
852 signal handler runs as promptly.
858 scheduleAlarm :: Int -> IO Int
864 <Literal>scheduleAlarm i</Literal> calls <Literal>alarm</Literal> to schedule a real time
865 alarm at least <Literal>i</Literal> seconds in the future.
871 sleep :: Int -> IO ()
877 <Literal>sleep i</Literal> calls <Literal>sleep</Literal> to suspend execution of the
878 program until at least <Literal>i</Literal> seconds have elapsed or a signal is
884 <Sect2 id="Process-Environment">
885 <Title>Posix Process Environment
889 <IndexTerm><Primary>Posix, process environment</Primary></IndexTerm>
895 getProcessID :: IO ProcessID
901 <Literal>getProcessID</Literal> calls <Literal>getpid</Literal> to obtain the <Literal>ProcessID</Literal> for
908 getParentProcessID :: IO ProcessID
914 <Literal>getProcessID</Literal> calls <Literal>getppid</Literal> to obtain the <Literal>ProcessID</Literal> for
915 the parent of the current process.
921 getRealUserID :: IO UserID
927 <Literal>getRealUserID</Literal> calls <Literal>getuid</Literal> to obtain the real <Literal>UserID</Literal>
928 associated with the current process.
934 getEffectiveUserID :: IO UserID
940 <Literal>getRealUserID</Literal> calls <Literal>geteuid</Literal> to obtain the effective
941 <Literal>UserID</Literal> associated with the current process.
947 setUserID :: UserID -> IO ()
953 <Literal>setUserID uid</Literal> calls <Literal>setuid</Literal> to set the real, effective, and
954 saved set-user-id associated with the current process to <Literal>uid</Literal>.
960 getLoginName :: IO String
966 <Literal>getLoginName</Literal> calls <Literal>getlogin</Literal> to obtain the login name
967 associated with the current process.
973 getRealGroupID :: IO GroupID
979 <Literal>getRealGroupID</Literal> calls <Literal>getgid</Literal> to obtain the real <Literal>GroupID</Literal>
980 associated with the current process.
986 getEffectiveGroupID :: IO GroupID
992 <Literal>getEffectiveGroupID</Literal> calls <Literal>getegid</Literal> to obtain the effective
993 <Literal>GroupID</Literal> associated with the current process.
999 setGroupID :: GroupID -> IO ()
1005 <Literal>setGroupID gid</Literal> calls <Literal>setgid</Literal> to set the real, effective, and
1006 saved set-group-id associated with the current process to <Literal>gid</Literal>.
1012 getGroups :: IO [GroupID]
1018 <Literal>getGroups</Literal> calls <Literal>getgroups</Literal> to obtain the list of
1019 supplementary <Literal>GroupID</Literal>s associated with the current process.
1025 getEffectiveUserName :: IO String
1031 <Literal>getEffectiveUserName</Literal> calls <Literal>cuserid</Literal> to obtain a name
1032 associated with the effective <Literal>UserID</Literal> of the process.
1038 getProcessGroupID :: IO ProcessGroupID
1044 <Literal>getProcessGroupID</Literal> calls <Literal>getpgrp</Literal> to obtain the
1045 <Literal>ProcessGroupID</Literal> for the current process.
1051 createProcessGroup :: ProcessID -> IO ProcessGroupID
1057 <Literal>createProcessGroup pid</Literal> calls <Literal>setpgid</Literal> to make
1058 process <Literal>pid</Literal> a new process group leader.
1064 joinProcessGroup :: ProcessGroupID -> IO ProcessGroupID
1070 <Literal>joinProcessGroup pgid</Literal> calls <Literal>setpgid</Literal> to set the
1071 <Literal>ProcessGroupID</Literal> of the current process to <Literal>pgid</Literal>.
1077 setProcessGroupID :: ProcessID -> ProcessGroupID -> IO ()
1083 <Literal>setProcessGroupID pid pgid</Literal> calls <Literal>setpgid</Literal> to set the
1084 <Literal>ProcessGroupID</Literal> for process <Literal>pid</Literal> to <Literal>pgid</Literal>.
1090 createSession :: IO ProcessGroupID
1096 <Literal>createSession</Literal> calls <Literal>setsid</Literal> to create a new session
1097 with the current process as session leader.
1103 systemName :: SystemID -> String
1104 nodeName :: SystemID -> String
1105 release :: SystemID -> String
1106 version :: SystemID -> String
1107 machine :: SystemID -> String
1109 getSystemID :: IO SystemID
1115 <Literal>getSystemID</Literal> calls <Literal>uname</Literal> to obtain information
1116 about the current operating system.
1122 > epochTime :: IO EpochTime
1128 <Literal>epochTime</Literal> calls <Literal>time</Literal> to obtain the number of
1129 seconds that have elapsed since the epoch (Jan 01 00:00:00 GMT 1970).
1135 elapsedTime :: ProcessTimes -> ClockTick
1136 userTime :: ProcessTimes -> ClockTick
1137 systemTime :: ProcessTimes -> ClockTick
1138 childUserTime :: ProcessTimes -> ClockTick
1139 childSystemTime :: ProcessTimes -> ClockTick
1141 getProcessTimes :: IO ProcessTimes
1147 <Literal>getProcessTimes</Literal> calls <Literal>times</Literal> to obtain time-accounting
1148 information for the current process and its children.
1154 getControllingTerminalName :: IO FilePath
1160 <Literal>getControllingTerminalName</Literal> calls <Literal>ctermid</Literal> to obtain
1161 a name associated with the controlling terminal for the process. If a
1162 controlling terminal exists,
1163 <Literal>getControllingTerminalName</Literal> returns the name of the
1164 controlling terminal.
1168 The operation may fail with:
1175 <Term><Literal>NoSuchThing</Literal></Term>
1178 There is no controlling terminal, or its name cannot be determined.
1183 <Term><Literal>SystemError</Literal></Term>
1186 Various other causes.
1196 getTerminalName :: Fd -> IO FilePath
1202 <Literal>getTerminalName fd</Literal> calls <Literal>ttyname</Literal> to obtain a name associated
1203 with the terminal for <Literal>Fd</Literal> <Literal>fd</Literal>. If <Literal>fd</Literal> is associated
1204 with a terminal, <Literal>getTerminalName</Literal> returns the name of the
1209 The operation may fail with:
1216 <Term><Literal>InappropriateType</Literal></Term>
1219 The channel is not associated with a terminal.
1224 <Term><Literal>NoSuchThing</Literal></Term>
1227 The channel is associated with a terminal, but it has no name.
1232 <Term><Literal>SystemError</Literal></Term>
1235 Various other causes.
1245 queryTerminal :: Fd -> IO Bool
1251 <Literal>queryTerminal fd</Literal> calls <Literal>isatty</Literal> to determine whether or
1252 not <Literal>Fd</Literal> <Literal>fd</Literal> is associated with a terminal.
1258 getSysVar :: SysVar -> IO Limit
1264 <Literal>getSysVar var</Literal> calls <Literal>sysconf</Literal> to obtain the
1265 dynamic value of the requested configurable system limit or option.
1266 For defined system limits, <Literal>getSysVar</Literal> returns the associated
1267 value. For defined system options, the result of <Literal>getSysVar</Literal>
1268 is undefined, but not failure.
1272 The operation may fail with:
1279 <Term><Literal>NoSuchThing</Literal></Term>
1282 The requested system limit or option is undefined.
1291 <Sect2 id="Files-and-Directories">
1292 <Title>Posix operations on files and directories
1296 <IndexTerm><Primary>Posix, files and directories</Primary></IndexTerm>
1302 openDirStream :: FilePath -> IO DirStream
1308 <Literal>openDirStream dir</Literal> calls <Literal>opendir</Literal> to obtain a
1309 directory stream for <Literal>dir</Literal>.
1315 readDirStream :: DirStream -> IO String
1321 <Literal>readDirStream dp</Literal> calls <Literal>readdir</Literal> to obtain the
1322 next directory entry (<Literal>struct dirent</Literal>) for the open directory
1323 stream <Literal>dp</Literal>, and returns the <Literal>d_name</Literal> member of that
1328 The operation may fail with:
1335 <Term><Literal>EOF</Literal></Term>
1338 End of file has been reached.
1343 <Term><Literal>SystemError</Literal></Term>
1346 Various other causes.
1356 rewindDirStream :: DirStream -> IO ()
1362 <Literal>rewindDirStream dp</Literal> calls <Literal>rewinddir</Literal> to reposition
1363 the directory stream <Literal>dp</Literal> at the beginning of the directory.
1369 closeDirStream :: DirStream -> IO ()
1375 <Literal>closeDirStream dp</Literal> calls <Literal>closedir</Literal> to close
1376 the directory stream <Literal>dp</Literal>.
1382 getWorkingDirectory :: IO FilePath
1388 <Literal>getWorkingDirectory</Literal> calls <Literal>getcwd</Literal> to obtain the name
1389 of the current working directory.
1395 changeWorkingDirectory :: FilePath -> IO ()
1401 <Literal>changeWorkingDirectory dir</Literal> calls <Literal>chdir</Literal> to change
1402 the current working directory to <Literal>dir</Literal>.
1407 nullFileMode :: FileMode -- ---------
1408 ownerReadMode :: FileMode -- r--------
1409 ownerWriteMode :: FileMode -- -w-------
1410 ownerExecuteMode :: FileMode -- --x------
1411 groupReadMode :: FileMode -- ---r-----
1412 groupWriteMode :: FileMode -- ----w----
1413 groupExecuteMode :: FileMode -- -----x---
1414 otherReadMode :: FileMode -- ------r--
1415 otherWriteMode :: FileMode -- -------w-
1416 otherExecuteMode :: FileMode -- --------x
1417 setUserIDMode :: FileMode -- --S------
1418 setGroupIDMode :: FileMode -- -----S---
1420 stdFileMode :: FileMode -- rw-rw-rw-
1422 ownerModes :: FileMode -- rwx------
1423 groupModes :: FileMode -- ---rwx---
1424 otherModes :: FileMode -- ------rwx
1425 accessModes :: FileMode -- rwxrwxrwx
1427 unionFileModes :: FileMode -> FileMode -> FileMode
1428 intersectFileModes :: FileMode -> FileMode -> FileMode
1431 stdInput = intToFd 0
1434 stdOutput = intToFd 1
1437 stdError = intToFd 2
1439 data OpenFileFlags =
1450 -> Maybe FileMode -- Just x => O_CREAT, Nothing => must exist
1451 -> OpenFileFlags
1457 <Literal>openFd path acc mode (OpenFileFlags app excl noctty nonblock trunc)</Literal> calls
1458 <Literal>open</Literal> to obtain a <Literal>Fd</Literal> for the file <Literal>path</Literal> with access
1459 mode <Literal>acc</Literal>. If <Literal>mode</Literal> is <Literal>Just m</Literal>, the <Literal>O_CREAT</Literal> flag is
1460 set and the file's permissions will be based on <Literal>m</Literal> if it does not
1461 already exist; otherwise, the <Literal>O_CREAT</Literal> flag is not set. The
1462 arguments <Literal>app</Literal>, <Literal>excl</Literal>, <Literal>noctty</Literal>, <Literal>nonblock</Literal>, and
1463 <Literal>trunc</Literal> control whether or not the flags <Literal>O_APPEND</Literal>,
1464 <Literal>O_EXCL</Literal>, <Literal>O_NOCTTY</Literal>, <Literal>O_NONBLOCK</Literal>, and <Literal>O_TRUNC</Literal> are set,
1471 createFile :: FilePath -> FileMode -> IO Fd
1477 <Literal>createFile path mode</Literal> calls <Literal>creat</Literal> to obtain a <Literal>Fd</Literal>
1478 for file <Literal>path</Literal>, which will be created with permissions based on
1479 <Literal>mode</Literal> if it does not already exist.
1485 setFileCreationMask :: FileMode -> IO FileMode
1491 <Literal>setFileCreationMask mode</Literal> calls <Literal>umask</Literal> to set
1492 the process's file creation mask to <Literal>mode</Literal>. The previous file
1493 creation mask is returned.
1499 createLink :: FilePath -> FilePath -> IO ()
1505 <Literal>createLink old new</Literal> calls <Literal>link</Literal> to create a
1506 new path, <Literal>new</Literal>, linked to an existing file, <Literal>old</Literal>.
1509 createDirectory :: FilePath -> FileMode -> IO ()
1515 <Literal>createDirectory dir mode</Literal> calls <Literal>mkdir</Literal> to
1516 create a new directory, <Literal>dir</Literal>, with permissions based on
1517 <Literal>mode</Literal>.
1523 createNamedPipe :: FilePath -> FileMode -> IO ()
1529 <Literal>createNamedPipe fifo mode</Literal> calls <Literal>mkfifo</Literal> to
1530 create a new named pipe, <Literal>fifo</Literal>, with permissions based on
1531 <Literal>mode</Literal>.
1537 removeLink :: FilePath -> IO ()
1543 <Literal>removeLink path</Literal> calls <Literal>unlink</Literal> to remove the link
1544 named <Literal>path</Literal>.
1550 removeDirectory :: FilePath -> IO ()
1556 <Literal>removeDirectory dir</Literal> calls <Literal>rmdir</Literal> to remove the
1557 directory named <Literal>dir</Literal>.
1563 rename :: FilePath -> FilePath -> IO ()
1569 <Literal>rename old new</Literal> calls <Literal>rename</Literal> to rename a
1570 file or directory from <Literal>old</Literal> to <Literal>new</Literal>.
1576 fileMode :: FileStatus -> FileMode
1578 fileID :: FileStatus -> FileID
1579 deviceID :: FileStatus -> DeviceID
1581 linkCount :: FileStatus -> LinkCount
1583 fileOwner :: FileStatus -> UserID
1584 fileGroup :: FileStatus -> GroupID
1585 fileSize :: FileStatus -> FileOffset
1587 accessTime :: FileStatus -> EpochTime
1588 modificationTime :: FileStatus -> EpochTime
1589 statusChangeTime :: FileStatus -> EpochTime
1591 isDirectory :: FileStatus -> Bool
1592 isCharacterDevice :: FileStatus -> Bool
1593 isBlockDevice :: FileStatus -> Bool
1594 isRegularFile :: FileStatus -> Bool
1595 isNamedPipe :: FileStatus -> Bool
1597 getFileStatus :: FilePath -> IO FileStatus
1603 <Literal>getFileStatus path</Literal> calls <Literal>stat</Literal> to get the
1604 <Literal>FileStatus</Literal> information for the file <Literal>path</Literal>.
1610 getFdStatus :: Fd -> IO FileStatus
1616 <Literal>getFdStatus fd</Literal> calls <Literal>fstat</Literal> to get the
1617 <Literal>FileStatus</Literal> information for the file associated with
1618 <Literal>Fd</Literal> <Literal>fd</Literal>.
1624 queryAccess :: FilePath -> Bool -> Bool -> Bool -> IO Bool
1630 <Literal>queryAccess path r w x</Literal> calls <Literal>access</Literal> to test the access
1631 permissions for file <Literal>path</Literal>. The three arguments, <Literal>r</Literal>, <Literal>w</Literal>,
1632 and <Literal>x</Literal> control whether or not <Literal>access</Literal> is called with
1633 <Literal>R_OK</Literal>, <Literal>W_OK</Literal>, and <Literal>X_OK</Literal> respectively.
1639 queryFile :: FilePath -> IO Bool
1645 <Literal>queryFile path</Literal> calls <Literal>access</Literal> with <Literal>F_OK</Literal> to test for the
1646 existence for file <Literal>path</Literal>.
1652 setFileMode :: FilePath -> FileMode -> IO ()
1658 <Literal>setFileMode path mode</Literal> calls <Literal>chmod</Literal> to set the
1659 permission bits associated with file <Literal>path</Literal> to <Literal>mode</Literal>.
1665 setOwnerAndGroup :: FilePath -> UserID -> GroupID -> IO ()
1671 <Literal>setOwnerAndGroup path uid gid</Literal> calls <Literal>chown</Literal> to
1672 set the <Literal>UserID</Literal> and <Literal>GroupID</Literal> associated with file
1673 <Literal>path</Literal> to <Literal>uid</Literal> and <Literal>gid</Literal>, respectively.
1679 setFileTimes :: FilePath -> EpochTime -> EpochTime -> IO ()
1685 <Literal>setFileTimes path atime mtime</Literal> calls <Literal>utime</Literal> to
1686 set the access and modification times associated with file
1687 <Literal>path</Literal> to <Literal>atime</Literal> and <Literal>mtime</Literal>, respectively.
1693 touchFile :: FilePath -> IO ()
1699 <Literal>touchFile path</Literal> calls <Literal>utime</Literal> to
1700 set the access and modification times associated with file
1701 <Literal>path</Literal> to the current time.
1707 getPathVar :: PathVar -> FilePath -> IO Limit
1713 <Literal>getPathVar var path</Literal> calls <Literal>pathconf</Literal> to obtain the
1714 dynamic value of the requested configurable file limit or option associated
1715 with file or directory <Literal>path</Literal>. For
1716 defined file limits, <Literal>getPathVar</Literal> returns the associated
1717 value. For defined file options, the result of <Literal>getPathVar</Literal>
1718 is undefined, but not failure.
1719 The operation may fail with:
1723 <Term><Literal>NoSuchThing</Literal></Term>
1726 The requested file limit or option is undefined.
1731 <Term><Literal>SystemError</Literal></Term>
1734 Various other causes.
1744 getFdVar :: PathVar -> Fd -> IO Limit
1750 <Literal>getFdVar var fd</Literal> calls <Literal>fpathconf</Literal> to obtain the
1751 dynamic value of the requested configurable file limit or option associated
1752 with the file or directory attached to the open channel <Literal>fd</Literal>.
1753 For defined file limits, <Literal>getFdVar</Literal> returns the associated
1754 value. For defined file options, the result of <Literal>getFdVar</Literal>
1755 is undefined, but not failure.
1759 The operation may fail with:
1766 <Term><Literal>NoSuchThing</Literal></Term>
1769 The requested file limit or option is undefined.
1774 <Term><Literal>SystemError</Literal></Term>
1777 Various other causes.
1786 <Sect2 id="Input-Output">
1787 <Title>Posix Input and Output Primitives
1791 <IndexTerm><Primary>Posix, input/output</Primary></IndexTerm>
1797 createPipe :: IO (Fd, Fd)
1803 <Literal>createPipe</Literal> calls <Literal>pipe</Literal> to create a pipe and returns a pair of
1804 <Literal>Fd</Literal>s, the first for reading and the second for writing.
1810 dup :: Fd -> IO Fd
1816 <Literal>dup fd</Literal> calls <Literal>dup</Literal> to duplicate <Literal>Fd</Literal> <Literal>fd</Literal> to
1817 another <Literal>Fd</Literal>.
1823 dupTo :: Fd -> Fd -> IO ()
1829 <Literal>dupTo src dst</Literal> calls <Literal>dup2</Literal> to duplicate <Literal>Fd</Literal>
1830 <Literal>src</Literal> to <Literal>Fd</Literal> <Literal>dst</Literal>.
1836 fdClose :: Fd -> IO ()
1842 <Literal>fdClose fd</Literal> calls <Literal>close</Literal> to close <Literal>Fd</Literal> <Literal>fd</Literal>.
1848 fdRead :: Fd -> ByteCount -> IO (String, ByteCount)
1854 <Literal>fdRead fd nbytes</Literal> calls <Literal>read</Literal> to read at most <Literal>nbytes</Literal>
1855 bytes from <Literal>Fd</Literal> <Literal>fd</Literal>, and returns the result as a string
1856 paired with the number of bytes actually read.
1860 The operation may fail with:
1867 <Term><Literal>EOF</Literal></Term>
1870 End of file has been reached.
1875 <Term><Literal>SystemError</Literal></Term>
1878 Various other causes.
1888 fdWrite :: Fd -> String -> IO ByteCount
1894 <Literal>fdWrite fd s</Literal> calls <Literal>write</Literal> to write
1895 the string <Literal>s</Literal> to <Literal>Fd</Literal> <Literal>fd</Literal> as a
1896 contiguous sequence of bytes. It returns the number of bytes successfully
1903 queryFdOption :: FdOption -> Fd -> IO Bool
1909 <Literal>getFdOption opt fd</Literal> calls <Literal>fcntl</Literal> to determine whether or
1910 not the flag associated with <Literal>FdOption</Literal> <Literal>opt</Literal> is set for
1911 <Literal>Fd</Literal> <Literal>fd</Literal>.
1917 setFdOption :: Fd -> FdOption -> Bool -> IO ()
1923 <Literal>setFdOption fd opt val</Literal> calls <Literal>fcntl</Literal> to set the flag
1924 associated with <Literal>FdOption</Literal> <Literal>opt</Literal> on <Literal>Fd</Literal> <Literal>fd</Literal> to
1925 <Literal>val</Literal>.
1931 getLock :: Fd -> FileLock -> IO (Maybe (ProcessID, FileLock))
1937 <Literal>getLock fd lock</Literal> calls <Literal>fcntl</Literal> to get the first <Literal>FileLock</Literal>
1938 for <Literal>Fd</Literal> <Literal>fd</Literal> which blocks the <Literal>FileLock</Literal> <Literal>lock</Literal>. If
1939 no such <Literal>FileLock</Literal> exists, <Literal>getLock</Literal> returns <Literal>Nothing</Literal>.
1940 Otherwise, it returns <Literal>Just (pid, block)</Literal>, where <Literal>block</Literal> is the
1941 blocking <Literal>FileLock</Literal> and <Literal>pid</Literal> is the <Literal>ProcessID</Literal> of the
1942 process holding the blocking <Literal>FileLock</Literal>.
1948 setLock :: Fd -> FileLock -> IO ()
1954 <Literal>setLock fd lock</Literal> calls <Literal>fcntl</Literal> with <Literal>F_SETLK</Literal> to set or
1955 clear a lock segment for <Literal>Fd</Literal> <Literal>fd</Literal> as indicated by the
1956 <Literal>FileLock</Literal> <Literal>lock</Literal>. <Literal>setLock</Literal> does not block, but fails with
1957 <Literal>SystemError</Literal> if the request cannot be satisfied immediately.
1963 waitToSetLock :: Fd -> FileLock -> IO ()
1969 <Literal>waitToSetLock fd lock</Literal> calls <Literal>fcntl</Literal> with <Literal>F_SETLKW</Literal> to set
1970 or clear a lock segment for <Literal>Fd</Literal> <Literal>fd</Literal> as indicated by the
1971 <Literal>FileLock</Literal> <Literal>lock</Literal>. If the request cannot be satisfied
1972 immediately, <Literal>waitToSetLock</Literal> blocks until the request can be
1979 fdSeek :: Fd -> SeekMode -> FileOffset -> IO FileOffset
1985 <Literal>fdSeek fd whence offset</Literal> calls <Literal>lseek</Literal> to position the
1986 <Literal>Fd</Literal> <Literal>fd</Literal> at the given <Literal>offset</Literal> from the starting location
1987 indicated by <Literal>whence</Literal>. It returns the resulting offset from the
1988 start of the file in bytes.
1993 <Sect2 id="Device-Specific-Functions">
1994 <Title>Posix, Device- and Class-Specific Functions
1998 <IndexTerm><Primary>Posix, device and class-specific functions</Primary></IndexTerm>
2004 terminalMode :: TerminalMode -> TerminalAttributes -> Bool
2005 withMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
2006 withoutMode :: TerminalAttributes -> TerminalMode -> TerminalAttributes
2008 bitsPerByte :: TerminalAttributes -> Int
2009 withBits :: TerminalAttributes -> Int -> TerminalAttributes
2011 controlChar :: TerminalAttributes -> ControlCharacter -> Maybe Char
2012 withCC :: TerminalAttributes
2013 -> (ControlCharacter, Char)
2014 -> TerminalAttributes
2015 withoutCC :: TerminalAttributes
2016 -> ControlCharacter
2017 -> TerminalAttributes
2019 inputTime :: TerminalAttributes -> Int
2020 withTime :: TerminalAttributes -> Int -> TerminalAttributes
2022 minInput :: TerminalAttributes -> Int
2023 withMinInput :: TerminalAttributes -> Int -> TerminalAttributes
2025 inputSpeed :: TerminalAttributes -> BaudRate
2026 withInputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes
2028 outputSpeed :: TerminalAttributes -> BaudRate
2029 withOutputSpeed :: TerminalAttributes -> BaudRate -> TerminalAttributes
2031 getTerminalAttributes :: Fd -> IO TerminalAttributes
2037 <Literal>getTerminalAttributes fd</Literal> calls <Literal>tcgetattr</Literal> to obtain
2038 the <Literal>TerminalAttributes</Literal> associated with <Literal>Fd</Literal> <Literal>fd</Literal>.
2044 setTerminalAttributes :: Fd
2045 -> TerminalAttributes
2046 -> TerminalState
2053 <Literal>setTerminalAttributes fd attr ts</Literal> calls <Literal>tcsetattr</Literal> to change
2054 the <Literal>TerminalAttributes</Literal> associated with <Literal>Fd</Literal> <Literal>fd</Literal> to
2055 <Literal>attr</Literal>, when the terminal is in the state indicated by <Literal>ts</Literal>.
2061 sendBreak :: Fd -> Int -> IO ()
2067 <Literal>sendBreak fd duration</Literal> calls <Literal>tcsendbreak</Literal> to transmit a
2068 continuous stream of zero-valued bits on <Literal>Fd</Literal> <Literal>fd</Literal> for the
2069 specified implementation-dependent <Literal>duration</Literal>.
2075 drainOutput :: Fd -> IO ()
2081 <Literal>drainOutput fd</Literal> calls <Literal>tcdrain</Literal> to block until all output
2082 written to <Literal>Fd</Literal> <Literal>fd</Literal> has been transmitted.
2088 discardData :: Fd -> QueueSelector -> IO ()
2094 <Literal>discardData fd queues</Literal> calls <Literal>tcflush</Literal> to discard
2095 pending input and/or output for <Literal>Fd</Literal> <Literal>fd</Literal>,
2096 as indicated by the <Literal>QueueSelector</Literal> <Literal>queues</Literal>.
2102 controlFlow :: Fd -> FlowAction -> IO ()
2108 <Literal>controlFlow fd action</Literal> calls <Literal>tcflow</Literal> to control the
2109 flow of data on <Literal>Fd</Literal> <Literal>fd</Literal>, as indicated by
2110 <Literal>action</Literal>.
2116 getTerminalProcessGroupID :: Fd -> IO ProcessGroupID
2122 <Literal>getTerminalProcessGroupID fd</Literal> calls <Literal>tcgetpgrp</Literal> to
2123 obtain the <Literal>ProcessGroupID</Literal> of the foreground process group
2124 associated with the terminal attached to <Literal>Fd</Literal> <Literal>fd</Literal>.
2130 setTerminalProcessGroupID :: Fd -> ProcessGroupID -> IO ()
2136 <Literal>setTerminalProcessGroupID fd pgid</Literal> calls <Literal>tcsetpgrp</Literal> to
2137 set the <Literal>ProcessGroupID</Literal> of the foreground process group
2138 associated with the terminal attached to <Literal>Fd</Literal>
2139 <Literal>fd</Literal> to <Literal>pgid</Literal>.
2144 <Sect2 id="System-Database">
2145 <Title>Posix System Databases
2149 <IndexTerm><Primary>Posix, system databases</Primary></IndexTerm>
2155 groupName :: GroupEntry -> String
2156 groupID :: GroupEntry -> GroupID
2157 groupMembers :: GroupEntry -> [String]
2159 getGroupEntryForID :: GroupID -> IO GroupEntry
2165 <Literal>getGroupEntryForID gid</Literal> calls <Literal>getgrgid</Literal> to obtain
2166 the <Literal>GroupEntry</Literal> information associated with <Literal>GroupID</Literal>
2167 <Literal>gid</Literal>.
2171 The operation may fail with:
2178 <Term><Literal>NoSuchThing</Literal></Term>
2181 There is no group entry for the GroupID.
2191 getGroupEntryForName :: String -> IO GroupEntry
2197 <Literal>getGroupEntryForName name</Literal> calls <Literal>getgrnam</Literal> to obtain
2198 the <Literal>GroupEntry</Literal> information associated with the group called
2199 <Literal>name</Literal>.
2203 The operation may fail with:
2210 <Term><Literal>NoSuchThing</Literal></Term>
2213 There is no group entry for the name.
2223 userName :: UserEntry -> String
2224 userID :: UserEntry -> UserID
2225 userGroupID :: UserEntry -> GroupID
2226 homeDirectory :: UserEntry -> String
2227 userShell :: UserEntry -> String
2229 getUserEntryForID :: UserID -> IO UserEntry
2235 <Literal>getUserEntryForID gid</Literal> calls <Literal>getpwuid</Literal> to obtain
2236 the <Literal>UserEntry</Literal> information associated with <Literal>UserID</Literal>
2237 <Literal>uid</Literal>.
2238 The operation may fail with:
2245 <Term><Literal>NoSuchThing</Literal></Term>
2248 There is no user entry for the UserID.
2258 getUserEntryForName :: String -> IO UserEntry
2264 <Literal>getUserEntryForName name</Literal> calls <Literal>getpwnam</Literal> to obtain
2265 the <Literal>UserEntry</Literal> information associated with the user login
2266 <Literal>name</Literal>.
2270 The operation may fail with:
2277 <Term><Literal>NoSuchThing</Literal></Term>
2280 There is no user entry for the name.
2289 <Sect2 id="Error-reporting-and-handling">
2294 <IndexTerm><Primary>Posix, errors</Primary></IndexTerm>
2300 getErrorCode :: IO ErrorCode
2306 <Literal>getErrorCode</Literal> returns the current value of the external
2307 variable <Literal>errno</Literal>. It never fails.
2313 setErrorCode :: ErrorCode -> IO ()
2319 <Literal>setErrorCode err</Literal> sets the external
2320 variable <Literal>errno</Literal> to <Literal>err</Literal>. It never fails.
2326 noError :: ErrorCode
2329 argumentListTooLong, e2BIG :: ErrorCode
2330 badFd, eBADF :: ErrorCode
2331 brokenPipe, ePIPE :: ErrorCode
2332 directoryNotEmpty, eNOTEMPTY :: ErrorCode
2333 execFormatError, eNOEXEC :: ErrorCode
2334 fileAlreadyExists, eEXIST :: ErrorCode
2335 fileTooLarge, eFBIG :: ErrorCode
2336 filenameTooLong, eNAMETOOLONG :: ErrorCode
2337 improperLink, eXDEV :: ErrorCode
2338 inappropriateIOControlOperation, eNOTTY :: ErrorCode
2339 inputOutputError, eIO :: ErrorCode
2340 interruptedOperation, eINTR :: ErrorCode
2341 invalidArgument, eINVAL :: ErrorCode
2342 invalidSeek, eSPIPE :: ErrorCode
2343 isADirectory, eISDIR :: ErrorCode
2344 noChildProcess, eCHILD :: ErrorCode
2345 noLocksAvailable, eNOLCK :: ErrorCode
2346 noSpaceLeftOnDevice, eNOSPC :: ErrorCode
2347 noSuchOperationOnDevice, eNODEV :: ErrorCode
2348 noSuchDeviceOrAddress, eNXIO :: ErrorCode
2349 noSuchFileOrDirectory, eNOENT :: ErrorCode
2350 noSuchProcess, eSRCH :: ErrorCode
2351 notADirectory, eNOTDIR :: ErrorCode
2352 notEnoughMemory, eNOMEM :: ErrorCode
2353 operationNotImplemented, eNOSYS :: ErrorCode
2354 operationNotPermitted, ePERM :: ErrorCode
2355 permissionDenied, eACCES :: ErrorCode
2356 readOnlyFileSystem, eROFS :: ErrorCode
2357 resourceBusy, eBUSY :: ErrorCode
2358 resourceDeadlockAvoided, eDEADLK :: ErrorCode
2359 resourceTemporarilyUnavailable, eAGAIN :: ErrorCode
2360 tooManyLinks, eMLINK :: ErrorCode
2361 tooManyOpenFiles, eMFILE :: ErrorCode
2362 tooManyOpenFilesInSystem, eNFILE :: ErrorCode