1.\"	$OpenBSD: intro.2,v 1.33 2005/08/18 15:18:19 jaredy Exp $
2.\"	$NetBSD: intro.2,v 1.6 1995/02/27 12:33:41 cgd Exp $
3.\"
4.\" Copyright (c) 1980, 1983, 1986, 1991, 1993
5.\"	The Regents of the University of California.  All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\" 1. Redistributions of source code must retain the above copyright
11.\"    notice, this list of conditions and the following disclaimer.
12.\" 2. Redistributions in binary form must reproduce the above copyright
13.\"    notice, this list of conditions and the following disclaimer in the
14.\"    documentation and/or other materials provided with the distribution.
15.\" 3. Neither the name of the University nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\"     @(#)intro.2	8.3 (Berkeley) 12/11/93
32.\"
33.Dd December 11, 1993
34.Dt INTRO 2
35.Os
36.Sh NAME
37.Nm intro
38.Nd introduction to system calls and error numbers
39.Sh SYNOPSIS
40.Fd #include <errno.h>
41.Sh DESCRIPTION
42The manual pages in section 2 provide an overview of the system calls,
43their error returns, and other common definitions and concepts.
44.\".Pp
45.\".Sy System call restart
46.\".Pp
47.\"<more later...>
48.Sh DIAGNOSTICS
49Nearly all of the system calls provide an error number in the external
50variable
51.Va errno ,
52which is currently defined as:
53.Pp
54.Dl extern int errno;
55.Pp
56Portable applications must not depend on this definition, and should only
57use
58.Va errno
59as defined in
60.Aq Pa errno.h .
61When a system call detects an error, it returns an integer value
62indicating failure (usually \-1) and sets the variable
63.Va errno
64accordingly.
65(This allows interpretation of the failure on receiving
66a \-1 and to take action accordingly.)
67Successful calls never set
68.Va errno ;
69once set, it remains until another error occurs.
70It should only be examined after an error.
71Note that a number of system calls overload the meanings of these
72error numbers, and that the meanings must be interpreted according
73to the type and circumstances of the call.
74.Pp
75The following is a complete list of the errors and their
76names as given in
77.Aq Pa sys/errno.h .
78.Bl -hang -width Ds
79.It Er 0 Em "Error 0" .
80Not used.
81.It Er 1 EPERM Em "Operation not permitted" .
82An attempt was made to perform an operation limited to processes
83with appropriate privileges or to the owner of a file or other
84resources.
85.It Er 2 ENOENT Em "No such file or directory" .
86A component of a specified pathname did not exist, or the
87pathname was an empty string.
88.It Er 3 ESRCH Em "No such process" .
89No process could be found corresponding to that specified by the given
90process ID.
91.It Er 4 EINTR Em "Interrupted function call" .
92An asynchronous signal (such as
93.Dv SIGINT
94or
95.Dv SIGQUIT )
96was caught by the process during the execution of an interruptible
97function.
98If the signal handler performs a normal return, the
99interrupted function call will seem to have returned the error condition.
100.It Er 5 EIO Em "Input/output error" .
101Some physical input or output error occurred.
102This error will not be reported until a subsequent operation on the same file
103descriptor and may be lost (over written) by any subsequent errors.
104.It Er 6 ENXIO Em "\&No such device or address" .
105Input or output on a special file referred to a device that did not
106exist, or made a request beyond the limits of the device.
107This error may also occur when, for example, a tape drive is not online or
108no disk pack is loaded on a drive.
109.It Er 7 E2BIG Em "Arg list too long" .
110The number of bytes used for the argument and environment
111list of the new process exceeded the limit
112.Dv NCARGS
113(specified in
114.Aq Pa sys/param.h ) .
115.It Er 8 ENOEXEC Em "Exec format error" .
116A request was made to execute a file that, although it has the appropriate
117permissions, was not in the format required for an executable file.
118.It Er 9 EBADF Em "Bad file descriptor" .
119A file descriptor argument was out of range, referred to no open file,
120or a read (write) request was made to a file that was only open for
121writing (reading).
122.It Er 10 ECHILD Em "\&No child processes" .
123A
124.Xr wait 2
125or
126.Xr waitpid 2
127function was executed by a process that had no existing or unwaited-for
128child processes.
129.It Er 11 EDEADLK Em "Resource deadlock avoided" .
130An attempt was made to lock a system resource that
131would have resulted in a deadlock situation.
132.It Er 12 ENOMEM Em "Cannot allocate memory" .
133The new process image required more memory than was allowed by the hardware
134or by system-imposed memory management constraints.
135A lack of swap space is normally temporary; however, a lack of core is not.
136Soft limits may be increased to their corresponding hard limits.
137.It Er 13 EACCES Em "Permission denied" .
138An attempt was made to access a file in a way forbidden
139by its file access permissions.
140.It Er 14 EFAULT Em "Bad address" .
141The system detected an invalid address in attempting to
142use an argument of a call.
143.It Er 15 ENOTBLK Em "Not a block device" .
144A block device operation was attempted on a non-block device or file.
145.It Er 16 EBUSY Em "Device busy" .
146An attempt to use a system resource which was in use at the time
147in a manner which would have conflicted with the request.
148.It Er 17 EEXIST Em "File exists" .
149An existing file was mentioned in an inappropriate context,
150for instance, as the new link name in a
151.Xr link 2
152function.
153.It Er 18 EXDEV Em "Improper link" .
154A hard link to a file on another file system was attempted.
155.It Er 19 ENODEV Em "Operation not supported by device" .
156An attempt was made to apply an inappropriate function to a device,
157for example, trying to read a write-only device such as a printer.
158.It Er 20 ENOTDIR Em "Not a directory" .
159A component of the specified pathname existed, but it was
160not a directory, when a directory was expected.
161.It Er 21 EISDIR Em "Is a directory" .
162An attempt was made to open a directory with write mode specified.
163.It Er 22 EINVAL Em "Invalid argument" .
164Some invalid argument was supplied.
165(For example, specifying an undefined signal to a
166.Xr signal 3
167or
168.Xr kill 2
169function).
170.It Er 23 ENFILE Em "Too many open files in system" .
171Maximum number of file descriptors allowable on the system
172has been reached and a request for an open cannot be satisfied
173until at least one has been closed.
174The
175.Xr sysctl 3
176variable
177.Va kern.maxfiles
178contains the current limit.
179.It Er 24 EMFILE Em "Too many open files" .
180The maximum number of file descriptors allowable for this process
181has been reached and a request for an open cannot be satisfied
182until at least one has been closed.
183.Xr getdtablesize 3
184will obtain the current limit.
185.It Er 25 ENOTTY Em "Inappropriate ioctl for device" .
186A control function (see
187.Xr ioctl 2 )
188was attempted for a file or
189special device for which the operation was inappropriate.
190.It Er 26 ETXTBSY Em "Text file busy" .
191The new process was a pure procedure (shared text) file
192which was open for writing by another process, or
193while the pure procedure file was being executed an
194.Xr open 2
195call requested write access.
196.It Er 27 EFBIG Em "File too large" .
197The size of a file exceeded the maximum.
198(The system-wide maximum file size is 2**63 bytes.
199Each file system may impose a lower limit for files contained within it.)
200.It Er 28 ENOSPC Em "Device out of space" .
201A
202.Xr write 2
203to an ordinary file, the creation of a directory or symbolic link,
204or the creation of a directory entry failed because no more disk
205blocks were available on the file system, or the allocation of an
206inode for a newly created file failed because no more inodes were
207available on the file system.
208.It Er 29 ESPIPE Em "Illegal seek" .
209An
210.Xr lseek 2
211function was issued on a socket, pipe or
212.Tn FIFO .
213.It Er 30 EROFS Em "Read-only file system" .
214An attempt was made to modify a file or create a directory
215on a file system that was read-only at the time.
216.It Er 31 EMLINK Em "Too many links" .
217The maximum allowable number of hard links to a single file has been
218exceeded (see
219.Xr pathconf 2
220for how to obtain this value).
221.It Er 32 EPIPE Em "Broken pipe" .
222A write on a pipe, socket or
223.Tn FIFO
224for which there is no process to read the data.
225.It Er 33 EDOM Em "Numerical argument out of domain" .
226A numerical input argument was outside the defined domain of
227the mathematical function.
228.It Er 34 ERANGE Em "Result out of range" .
229A result of the function was too large to fit in the
230available space (perhaps exceeded precision).
231.It Er 35 EAGAIN Em "Resource temporarily unavailable" .
232This is a temporary condition and later calls to the
233same routine may complete normally.
234.It Er 36 EINPROGRESS Em "Operation now in progress" .
235An operation that takes a long time to complete (such as a
236.Xr connect 2 )
237was attempted on a non-blocking object (see
238.Xr fcntl 2 ) .
239.It Er 37 EALREADY Em "Operation already in progress" .
240An operation was attempted on a non-blocking object that already
241had an operation in progress.
242.It Er 38 ENOTSOCK Em "Socket operation on non-socket" .
243Self-explanatory.
244.It Er 39 EDESTADDRREQ Em "Destination address required" .
245A required address was omitted from an operation on a socket.
246.It Er 40 EMSGSIZE Em "Message too long" .
247A message sent on a socket was larger than the internal message buffer
248or some other network limit.
249.It Er 41 EPROTOTYPE Em "Protocol wrong type for socket" .
250A protocol was specified that does not support the semantics of the
251socket type requested.
252For example, you cannot use the
253.Tn ARPA
254Internet
255.Tn UDP
256protocol with type
257.Dv SOCK_STREAM .
258.It Er 42 ENOPROTOOPT Em "Protocol not available" .
259A bad option or level was specified in a
260.Xr getsockopt 2
261or
262.Xr setsockopt 2
263call.
264.It Er 43 EPROTONOSUPPORT Em "Protocol not supported" .
265The protocol has not been configured into the
266system or no implementation for it exists.
267.It Er 44 ESOCKTNOSUPPORT Em "Socket type not supported" .
268The support for the socket type has not been configured into the
269system or no implementation for it exists.
270.It Er 45 EOPNOTSUPP Em "Operation not supported" .
271The attempted operation is not supported for the type of object referenced.
272Usually this occurs when a file descriptor refers to a file or socket
273that cannot support this operation, for example, trying to
274.Em accept
275a connection on a datagram socket.
276.It Er 46 EPFNOSUPPORT Em "Protocol family not supported" .
277The protocol family has not been configured into the
278system or no implementation for it exists.
279.It Er 47 EAFNOSUPPORT Em "Address family not supported by protocol family" .
280An address incompatible with the requested protocol was used.
281For example, you shouldn't necessarily expect to be able to use
282.Tn NS
283addresses with
284.Tn ARPA
285Internet protocols.
286.It Er 48 EADDRINUSE Em "Address already in use" .
287Only one usage of each address is normally permitted.
288.It Er 49 EADDRNOTAVAIL Em "Cannot assign requested address" .
289Normally results from an attempt to create a socket with an
290address not on this machine.
291.It Er 50 ENETDOWN Em "Network is down" .
292A socket operation encountered a dead network.
293.It Er 51 ENETUNREACH Em "Network is unreachable" .
294A socket operation was attempted to an unreachable network.
295.It Er 52 ENETRESET Em "Network dropped connection on reset" .
296The host you were connected to crashed and rebooted.
297.It Er 53 ECONNABORTED Em "Software caused connection abort" .
298A connection abort was caused internal to your host machine.
299.It Er 54 ECONNRESET Em "Connection reset by peer" .
300A connection was forcibly closed by a peer.
301This normally results from a loss of the connection on the remote socket
302due to a timeout or a reboot.
303.It Er 55 ENOBUFS Em "\&No buffer space available" .
304An operation on a socket or pipe was not performed because
305the system lacked sufficient buffer space or because a queue was full.
306.It Er 56 EISCONN Em "Socket is already connected" .
307A
308.Xr connect 2
309request was made on an already connected socket; or, a
310.Xr sendto 2
311or
312.Xr sendmsg 2
313request on a connected socket specified a destination
314when already connected.
315.It Er 57 ENOTCONN Em "Socket is not connected" .
316A request to send or receive data was disallowed because
317the socket was not connected and (when sending on a datagram socket)
318no address was supplied.
319.It Er 58 ESHUTDOWN Em "Cannot send after socket shutdown" .
320A request to send data was disallowed because the socket
321had already been shut down with a previous
322.Xr shutdown 2
323call.
324.It Er 59 ETOOMANYREFS Em "Too many references: can't splice" .
325Not used in
326.Ox .
327.It Er 60 ETIMEDOUT Em "Operation timed out" .
328A
329.Xr connect 2
330or
331.Xr send 2
332request failed because the connected party did not
333properly respond after a period of time.
334(The timeout period is dependent on the communication protocol.)
335.It Er 61 ECONNREFUSED Em "Connection refused" .
336No connection could be made because the target machine actively
337refused it.
338This usually results from trying to connect to a service that is
339inactive on the foreign host.
340.It Er 62 ELOOP Em "Too many levels of symbolic links" .
341A path name lookup involved more than 32
342.Pq Dv SYMLOOP_MAX
343symbolic links.
344.It Er 63 ENAMETOOLONG Em "File name too long" .
345A component of a path name exceeded 255
346.Pq Dv MAXNAMELEN
347characters, or an entire path name exceeded 1023
348.Pq Dv MAXPATHLEN Ns -1
349characters.
350.It Er 64 EHOSTDOWN Em "Host is down" .
351A socket operation failed because the destination host was down.
352.It Er 65 EHOSTUNREACH Em "No route to host" .
353A socket operation was attempted to an unreachable host.
354.It Er 66 ENOTEMPTY Em "Directory not empty" .
355A directory with entries other than
356.Ql \&.
357and
358.Ql \&..
359was supplied to a remove directory or rename call.
360.It Er 67 EPROCLIM Em "Too many processes" .
361.It Er 68 EUSERS Em "Too many users" .
362The quota system ran out of table entries.
363.It Er 69 EDQUOT Em "Disc quota exceeded" .
364A
365.Xr write 2
366to an ordinary file, the creation of a directory or symbolic link,
367or the creation of a directory entry failed because the user's quota
368of disk blocks was exhausted, or the allocation of an inode for a newly
369created file failed because the user's quota of inodes was exhausted.
370.It Er 70 ESTALE Em "Stale NFS file handle" .
371An attempt was made to access an open file (on an
372.Tn NFS
373filesystem) which is now unavailable as referenced by the file descriptor.
374This may indicate the file was deleted on the
375.Tn NFS
376server or some
377other catastrophic event occurred.
378.It Er 72 EBADRPC Em "RPC struct is bad" .
379Exchange of
380.Tn RPC
381information was unsuccessful.
382.It Er 73 ERPCMISMATCH Em "RPC version wrong" .
383The version of
384.Tn RPC
385on the remote peer is not compatible with the local version.
386.It Er 74 EPROGUNAVAIL Em "RPC prog. not avail" .
387The requested program is not registered on the remote host.
388.It Er 75 EPROGMISMATCH Em "Program version wrong" .
389The requested version of the program is not available on the remote host
390.Pq Tn RPC .
391.It Er 76 EPROCUNAVAIL Em "Bad procedure for program" .
392An
393.Tn RPC
394call was attempted for a procedure which doesn't exist
395in the remote program.
396.It Er 77 ENOLCK Em "No locks available" .
397A system-imposed limit on the number of simultaneous file
398locks was reached.
399.It Er 78 ENOSYS Em "Function not implemented" .
400Attempted a system call that is not available on this
401system.
402.It Er 79 EFTYPE Em "Inappropriate file type or format" .
403The file contains invalid data or set to invalid modes.
404.It Er 80 EAUTH Em "Authentication error" .
405Attempted to use an invalid authentication ticket to mount a
406.Tn NFS
407filesystem.
408.It Er 81 ENEEDAUTH Em "Need authenticator" .
409An authentication ticket must be obtained before the given
410.Tn NFS
411filesystem may be mounted.
412.It Er 82 EIPSEC Em "IPsec processing failure" .
413IPsec subsystem error.
414Not used in
415.Ox .
416.It Er 83 ENOATTR Em "Attribute not found" .
417A UFS Extended Attribute is not found for the specified pathname.
418.El
419.Sh DEFINITIONS
420.Bl -tag -width Ds
421.It Process ID
422Each active process in the system is uniquely identified by a non-negative
423integer called a process ID.
424The range of this ID is from 1 to 32766.
425.It Parent Process ID
426A new process is created by a currently active process; (see
427.Xr fork 2 ) .
428The parent process ID of a process is initially the process ID of its creator.
429If the creating process exits,
430the parent process ID of each child is set to the ID of a system process,
431.Xr init 8 .
432.It Process Group
433Each active process is a member of a process group that is identified by
434a non-negative integer called the process group ID.
435This is the process ID of the group leader.
436This grouping permits the signaling of related processes (see
437.Xr termios 4 )
438and the job control mechanisms of
439.Xr csh 1 .
440.It Session
441A session is a set of one or more process groups.
442A session is created by a successful call to
443.Xr setsid 2 ,
444which causes the caller to become the only member of the only process
445group in the new session.
446.It Session Leader
447A process that has created a new session by a successful call to
448.Xr setsid 2 ,
449is known as a session leader.
450Only a session leader may acquire a terminal as its controlling terminal (see
451.Xr termios 4 ) .
452.It Controlling Process
453A session leader with a controlling terminal is a controlling process.
454.It Controlling Terminal
455A terminal that is associated with a session is known as the controlling
456terminal for that session and its members.
457.It Terminal Process Group ID
458A terminal may be acquired by a session leader as its controlling terminal.
459Once a terminal is associated with a session, any of the process groups
460within the session may be placed into the foreground by setting
461the terminal process group ID to the ID of the process group.
462This facility is used
463to arbitrate between multiple jobs contending for the same terminal;
464(see
465.Xr csh 1
466and
467.Xr tty 4 ) .
468.It Orphaned Process Group
469A process group is considered to be
470.Em orphaned
471if it is not under the control of a job control shell.
472More precisely, a process group is orphaned
473when none of its members has a parent process that is in the same session
474as the group,
475but is in a different process group.
476Note that when a process exits, the parent process for its children
477is changed to be
478.Xr init 8 ,
479which is in a separate session.
480Not all members of an orphaned process group are necessarily orphaned
481processes (those whose creating process has exited).
482The process group of a session leader is orphaned by definition.
483.It Real User ID and Real Group ID
484Each user on the system is identified by a positive integer
485termed the real user ID.
486.Pp
487Each user is also a member of one or more groups.
488One of these groups is distinguished from others and
489used in implementing accounting facilities.
490The positive integer corresponding to this distinguished group is termed
491the real group ID.
492.Pp
493All processes have a real user ID and real group ID.
494These are initialized from the equivalent attributes
495of the process that created it.
496.It "Effective User ID, Effective Group ID, and Group Access List"
497Access to system resources is governed by two values:
498the effective user ID, and the group access list.
499The first member of the group access list is also known as the
500effective group ID.
501(In POSIX.1, the group access list is known as the set of supplementary
502group IDs, and it is unspecified whether the effective group ID is
503a member of the list.)
504.Pp
505The effective user ID and effective group ID are initially the
506process's real user ID and real group ID respectively.
507Either may be modified through execution of a set-user-ID or set-group-ID
508file (possibly by one of its ancestors) (see
509.Xr execve 2 ) .
510By convention, the effective group ID (the first member of the group access
511list) is duplicated, so that the execution of a set-group-ID program
512does not result in the loss of the original (real) group ID.
513.Pp
514The group access list is a set of group IDs
515used only in determining resource accessibility.
516Access checks are performed as described below in ``File Access Permissions''.
517.It Saved Set User ID and Saved Set Group ID
518When a process executes a new file, the effective user ID is set
519to the owner of the file if the file is set-user-ID, and the effective
520group ID (first element of the group access list) is set to the group
521of the file if the file is set-group-ID.
522The effective user ID of the process is then recorded as the saved set-user-ID,
523and the effective group ID of the process is recorded as the saved set-group-ID.
524These values may be used to regain those values as the effective user
525or group ID after reverting to the real ID (see
526.Xr setuid 2 ) .
527(In POSIX.1, the saved set-user-ID and saved set-group-ID are optional,
528and are used in setuid and setgid, but this does not work as desired
529for the superuser.)
530.It Superuser
531A process is recognized as a
532.Em superuser
533process and is granted special privileges if its effective user ID is 0.
534.It Special Processes
535The processes with process IDs of 0, 1, and 2 are special.
536Process 0 is the scheduler.
537Process 1 is the initialization process
538.Xr init 8 ,
539and is the ancestor of every other process in the system.
540It is used to control the process structure.
541Process 2 is the paging daemon.
542.It Descriptor
543An integer assigned by the system when a file is referenced
544by
545.Xr open 2
546or
547.Xr dup 2 ,
548or when a socket is created by
549.Xr pipe 2 ,
550.Xr socket 2
551or
552.Xr socketpair 2 ,
553which uniquely identifies an access path to that file or socket from
554a given process or any of its children.
555.It File Name
556Names consisting of up to 255
557.Pq Dv MAXNAMELEN
558characters may be used to name
559an ordinary file, special file, or directory.
560.Pp
561These characters may be selected from the set of all
562.Tn ASCII
563character
564excluding 0 (NUL) and the
565.Tn ASCII
566code for
567.Ql \&/
568(slash).
569.Pp
570Note that it is generally unwise to use
571.Ql \&* ,
572.Ql \&? ,
573.Ql \&[
574or
575.Ql \&]
576as part of
577file names because of the special meaning attached to these characters
578by the shell.
579.Pp
580Note also that
581.Pq Dv MAXNAMELEN
582is an upper limit fixed by the kernel, meant to be used for sizing buffers.
583Some filesystems may have additional restrictions.
584These can be queried using
585.Xr pathconf 2
586and
587.Xr fpathconf 2 .
588.It Path Name
589A path name is a
590.Tn NUL Ns -terminated
591character string starting with an
592optional slash
593.Ql \&/ ,
594followed by zero or more directory names separated
595by slashes, optionally followed by a file name.
596The total length of a path name must be less than 1024
597.Pq Dv MAXPATHLEN
598characters.
599Additional restrictions may apply, depending upon the filesystem, to be
600queried with
601.Xr pathconf 2
602or
603.Xr fpathconf 2
604if needed.
605.Pp
606If a path name begins with a slash, the path search begins at the
607.Em root
608directory.
609Otherwise, the search begins from the current working directory.
610A slash by itself names the root directory.
611An empty pathname is invalid.
612.It Directory
613A directory is a special type of file that contains entries
614that are references to other files.
615Directory entries are called links.
616By convention, a directory contains at least two links,
617.Ql \&.
618and
619.Ql \&.. ,
620referred to as
621.Em dot
622and
623.Em dot-dot
624respectively.
625Dot refers to the directory itself and dot-dot refers to its
626parent directory.
627.It "Root Directory and Current Working Directory"
628Each process has associated with it a concept of a root directory
629and a current working directory for the purpose of resolving path
630name searches.
631A process's root directory need not be the root directory of
632the root file system.
633.It File Access Permissions
634Every file in the file system has a set of access permissions.
635These permissions are used in determining whether a process
636may perform a requested operation on the file (such as opening
637a file for writing).
638Access permissions are established at the time a file is created.
639They may be changed at some later time through the
640.Xr chmod 2
641call.
642.Pp
643File access is broken down according to whether a file may be: read,
644written, or executed.
645Directory files use the execute permission to control if the directory
646may be searched.
647.Pp
648File access permissions are interpreted by the system as
649they apply to three different classes of users: the owner
650of the file, those users in the file's group, anyone else.
651Every file has an independent set of access permissions for
652each of these classes.
653When an access check is made, the system decides if permission should be
654granted by checking the access information applicable to the caller.
655.Pp
656Read, write, and execute/search permissions on
657a file are granted to a process if:
658.Pp
659The process's effective user ID is that of the superuser.
660(Note: even the superuser cannot execute a non-executable file.)
661.Pp
662The process's effective user ID matches the user ID of the owner
663of the file and the owner permissions allow the access.
664.Pp
665The process's effective user ID does not match the user ID of the
666owner of the file, and either the process's effective
667group ID matches the group ID
668of the file, or the group ID of the file is in
669the process's group access list,
670and the group permissions allow the access.
671.Pp
672Neither the effective user ID nor effective group ID
673and group access list of the process
674match the corresponding user ID and group ID of the file,
675but the permissions for ``other users'' allow access.
676.Pp
677Otherwise, permission is denied.
678.It Sockets and Address Families
679A socket is an endpoint for communication between processes.
680Each socket has queues for sending and receiving data.
681.Pp
682Sockets are typed according to their communications properties.
683These properties include whether messages sent and received
684at a socket require the name of the partner, whether communication
685is reliable, the format used in naming message recipients, etc.
686.Pp
687Each instance of the system supports some
688collection of socket types; consult
689.Xr socket 2
690for more information about the types available and
691their properties.
692.Pp
693Each instance of the system supports some number of sets of
694communications protocols.
695Each protocol set supports addresses of a certain format.
696An Address Family is the set of addresses for a specific group of protocols.
697Each socket has an address chosen from the address family in which the
698socket was created.
699.El
700.Sh SEE ALSO
701.Xr intro 3 ,
702.Xr perror 3
703.Sh HISTORY
704An
705.Nm
706manual page appeared in
707.At v6 .
708