1*68456Smckusick.\" Copyright (c) 1980, 1983, 1986, 1991, 1993 261181Sbostic.\" The Regents of the University of California. All rights reserved. 320110Smckusick.\" 447208Scael.\" %sccs.include.redist.man% 520110Smckusick.\" 6*68456Smckusick.\" @(#)intro.2 8.5 (Berkeley) 02/27/95 747208Scael.\" 847208Scael.Dd 947208Scael.Dt INTRO 2 1047208Scael.Os BSD 4 1147208Scael.Sh NAME 1247208Scael.Nm intro 1347208Scael.Nd introduction to system calls and error numbers 1447208Scael.Sh SYNOPSIS 1558263Smckusick.Fd #include <sys/errno.h> 1647208Scael.Sh DESCRIPTION 1744667SkarelsThis section provides an overview of the system calls, 1844667Skarelstheir error returns, and other common definitions and concepts. 1947208Scael.\".Pp 2047208Scael.\".Sy System call restart 2147208Scael.\".Pp 2244667Skarels.\"<more later...> 2347208Scael.Sh DIAGNOSTICS 2447208ScaelNearly all of the system calls provide an error number in the external 2547208Scaelvariable 2647208Scael.Va errno , 2747208Scaelwhich is defined as: 2847208Scael.Pp 2947208Scael.Dl extern int errno 3047208Scael.Pp 3147208ScaelWhen a system call detects an error, 3247208Scaelit returns an integer value 3347208Scaelindicating failure (usually -1) 3447208Scaeland sets the variable 3547208Scael.Va errno 3647208Scaelaccordingly. 3747208Scael<This allows interpretation of the failure on receiving 3847208Scaela -1 and to take action accordingly.> 3947208ScaelSuccessful calls never set 4047208Scael.Va errno ; 4147208Scaelonce set, it remains until another error occurs. 4247208ScaelIt should only be examined after an error. 4328185SkarelsNote that a number of system calls overload the meanings of these 4428185Skarelserror numbers, and that the meanings must be interpreted according 4528185Skarelsto the type and circumstances of the call. 4647208Scael.Pp 4720111SmckusickThe following is a complete list of the errors and their 4820111Smckusicknames as given in 4947208Scael.Aq Pa sys/errno.h . 5047208Scael.Bl -hang -width Ds 5147208Scael.It Er 0 Em "Error 0" . 5247208ScaelNot used. 5365100Smckusick.It Er 1 EPERM Em "Operation not permitted" . 5447208ScaelAn attempt was made to perform an operation limited to processes 5547208Scaelwith appropriate privileges or to the owner of a file or other 5647208Scaelresources. 5747208Scael.It Er 2 ENOENT Em "No such file or directory" . 5847208ScaelA component of a specified pathname did not exist, or the 5947208Scaelpathname was an empty string. 6047208Scael.It Er 3 ESRCH Em "No such process" . 6147208ScaelNo process could be found corresponding to that specified by the given 6247208Scaelprocess ID. 6347208Scael.It Er 4 EINTR Em "Interrupted function call" . 6447208ScaelAn asynchronous signal (such as 6547208Scael.Dv SIGINT 6620110Smckusickor 6747208Scael.Dv SIGQUIT ) 6847208Scaelwas caught by the process during the execution of an interruptible 6947208Scaelfunction. If the signal handler performs a normal return, the 7058263Smckusickinterrupted function call will seem to have returned the error condition. 7147208Scael.It Er 5 EIO Em "Input/output error" . 7247208ScaelSome physical input or output error occurred. 7365100SmckusickThis error will not be reported until a subsequent operation on the same file 7447208Scaeldescriptor and may be lost (over written) by any subsequent errors. 7547208Scael.It Er 6 ENXIO Em "\&No such device or address" . 7647208ScaelInput or output on a special file referred to a device that did not 7747208Scaelexist, or 7847208Scaelmade a request beyond the limits of the device. 7947208ScaelThis error may also occur when, for example, 8047208Scaela tape drive is not online or no disk pack is 8165100Smckusickloaded on a drive. 8247208Scael.It Er 7 E2BIG Em "Arg list too long" . 8347208ScaelThe number of bytes used for the argument and environment 8447208Scaellist of the new process exceeded the current limit 8547208Scaelof 20480 bytes 8647208Scael.Pf ( Dv NCARGS 8747208Scaelin 8847208Scael.Aq Pa sys/param.h ) . 8947208Scael.It Er 8 ENOEXEC Em "Exec format error" . 9047208ScaelA request was made to execute a file 9123809Ssechrestthat, although it has the appropriate permissions, 9247208Scaelwas not in the format required for an 9347208Scaelexecutable file. 9447208Scael.It Er 9 EBADF Em "Bad file descriptor" . 9547208ScaelA file descriptor argument was out of range, referred to no open file, 9647208Scaelor a read (write) request was made to a file that was only open for 9747208Scaelwriting (reading). 9867356Sah.sp 9947208Scael.It Er 10 ECHILD Em "\&No child processes" . 10047208ScaelA 10147208Scael.Xr wait 10247208Scaelor 10347208Scael.Xr waitpid 10447208Scaelfunction was executed by a process that had no existing or unwaited-for 10547208Scaelchild processes. 10647208Scael.It Er 11 EDEADLK Em "Resource deadlock avoided" . 10744763StrentAn attempt was made to lock a system resource that 10844763Strentwould have resulted in a deadlock situation. 10958263Smckusick.It Er 12 ENOMEM Em "Cannot allocate memory" . 11047208ScaelThe new process image required more memory than was allowed by the hardware 11147208Scaelor by system-imposed memory management constraints. 11247208ScaelA lack of swap space is normally temporary; however, 11347208Scaela lack of core is not. 11428185SkarelsSoft limits may be increased to their corresponding hard limits. 11547208Scael.It Er 13 EACCES Em "Permission denied" . 11620110SmckusickAn attempt was made to access a file in a way forbidden 11747208Scaelby its file access permissions. 11847208Scael.It Er 14 EFAULT Em "Bad address" . 11947208ScaelThe system detected an invalid address in attempting to 12047208Scaeluse an argument of a call. 12147208Scael.It Er 15 ENOTBLK Em "Not a block device" . 12247208ScaelA block device operation was attempted on a non-block device or file. 12347208Scael.It Er 16 EBUSY Em "Resource busy" . 12447208ScaelAn attempt to use a system resource which was in use at the time 12547208Scaelin a manner which would have conflicted with the request. 12647208Scael.It Er 17 EEXIST Em "File exists" . 12720110SmckusickAn existing file was mentioned in an inappropriate context, 12847208Scaelfor instance, as the new link name in a 12947208Scael.Xr link 13047208Scaelfunction. 13147208Scael.It Er 18 EXDEV Em "Improper link" . 13247208ScaelA hard link to a file on another file system 13320110Smckusickwas attempted. 13447208Scael.It Er 19 ENODEV Em "Operation not supported by device" . 13520110SmckusickAn attempt was made to apply an inappropriate 13647208Scaelfunction to a device, 13747208Scaelfor example, 13847208Scaeltrying to read a write-only device such as a printer. 13947208Scael.It Er 20 ENOTDIR Em "Not a directory" . 14047208ScaelA component of the specified pathname existed, but it was 14147208Scaelnot a directory, when a directory was expected. 14247208Scael.It Er 21 EISDIR Em "Is a directory" . 14347208ScaelAn attempt was made to open a directory with write mode specified. 14447208Scael.It Er 22 EINVAL Em "Invalid argument" . 14547208ScaelSome invalid argument was supplied. (For example, 14647208Scaelspecifying an undefined signal to a 14747208Scael.Xr signal 14847208Scaelor 14947208Scael.Xr kill 15047208Scaelfunction). 15147208Scael.It Er 23 ENFILE Em "Too many open files in system" . 15247208ScaelMaximum number of file descriptors allowable on the system 15347208Scaelhas been reached and a requests for an open cannot be satisfied 15447208Scaeluntil at least one has been closed. 15547208Scael.It Er 24 EMFILE Em "Too many open files" . 15647208Scael<As released, the limit on the number of 15747208Scaelopen files per process is 64.> 15847208Scael.Xr Getdtablesize 2 15928185Skarelswill obtain the current limit. 16047208Scael.It Er 25 ENOTTY Em "Inappropriate ioctl for device" . 16147208ScaelA control function (see 16247208Scael.Xr ioctl 2 ) 16347208Scaelwas attempted for a file or 16447208Scaelspecial device for which the operation was inappropriate. 16547208Scael.It Er 26 ETXTBSY Em "Text file busy" . 16647208ScaelThe new process was a pure procedure (shared text) file 16747208Scaelwhich was open for writing by another process, or 16865100Smckusickwhile the pure procedure file was being executed an 16947208Scael.Xr open 17047208Scaelcall requested write access. 17147208Scael.It Er 27 EFBIG Em "File too large" . 17220110SmckusickThe size of a file exceeded the maximum (about 17328185Skarels.if t 2\u\s-231\s+2\d 17428185Skarels.if n 2.1E9 17520110Smckusickbytes). 17647208Scael.It Er 28 ENOSPC Em "Device out of space" . 17724439SmckusickA 17847208Scael.Xr write 17924439Smckusickto an ordinary file, the creation of a 18024439Smckusickdirectory or symbolic link, or the creation of a directory 18165100Smckusickentry failed because no more disk blocks were available 18224439Smckusickon the file system, or the allocation of an inode for a newly 18365100Smckusickcreated file failed because no more inodes were available 18424439Smckusickon the file system. 18547208Scael.It Er 29 ESPIPE Em "Illegal seek" . 18620110SmckusickAn 18747208Scael.Xr lseek 18847208Scaelfunction was issued on a socket, pipe or 18947208Scael.Tn FIFO . 19047208Scael.It Er 30 EROFS Em "Read-only file system" . 19147208ScaelAn attempt was made to modify a file or directory 19220110Smckusickwas made 19347208Scaelon a file system that was read-only at the time. 19447208Scael.It Er 31 EMLINK Em "Too many links" . 19547208ScaelMaximum allowable hard links to a single file has been exceeded (limit 19647208Scaelof 32767 hard links per file). 19747208Scael.It Er 32 EPIPE Em "Broken pipe" . 19847208ScaelA write on a pipe, socket or 19947208Scael.Tn FIFO 20047208Scaelfor which there is no process 20120110Smckusickto read the data. 20247208Scael.It Er 33 EDOM Em "Numerical argument out of domain" . 20347208ScaelA numerical input argument was outside the defined domain of the mathematical 20447208Scaelfunction. 20547208Scael.It Er 34 ERANGE Em "Numerical result out of range" . 20665100SmckusickA numerical result of the function was too large to fit in the 20747208Scaelavailable space (perhaps exceeded precision). 20847208Scael.It Er 35 EAGAIN Em "Resource temporarily unavailable" . 20944763StrentThis is a temporary condition and later calls to the 21044763Strentsame routine may complete normally. 21147208Scael.It Er 36 EINPROGRESS Em "Operation now in progress" . 21223809SsechrestAn operation that takes a long time to complete (such as 21347208Scaela 21447208Scael.Xr connect 2 ) 21547208Scaelwas attempted on a non-blocking object (see 21647208Scael.Xr fcntl 2 ) . 21747208Scael.It Er 37 EALREADY Em "Operation already in progress" . 21823809SsechrestAn operation was attempted on a non-blocking object that already 21920111Smckusickhad an operation in progress. 22047208Scael.It Er 38 ENOTSOCK Em "Socket operation on non-socket" . 22120111SmckusickSelf-explanatory. 22247208Scael.It Er 39 EDESTADDRREQ Em "Destination address required" . 22320111SmckusickA required address was omitted from an operation on a socket. 22447208Scael.It Er 40 EMSGSIZE Em "Message too long" . 22528185SkarelsA message sent on a socket was larger than the internal message buffer 22628185Skarelsor some other network limit. 22747208Scael.It Er 41 EPROTOTYPE Em "Protocol wrong type for socket" . 22823809SsechrestA protocol was specified that does not support the semantics of the 22947208Scaelsocket type requested. For example, you cannot use the 23047208Scael.Tn ARPA 23147208ScaelInternet 23247208Scael.Tn UDP 23347208Scaelprotocol with type 23447208Scael.Dv SOCK_STREAM . 23547208Scael.It Er 42 ENOPROTOOPT Em "Protocol not available" . 23628185SkarelsA bad option or level was specified in a 23747208Scael.Xr getsockopt 2 23820111Smckusickor 23947208Scael.Xr setsockopt 2 24020111Smckusickcall. 24147208Scael.It Er 43 EPROTONOSUPPORT Em "Protocol not supported" . 24220111SmckusickThe protocol has not been configured into the 24320111Smckusicksystem or no implementation for it exists. 24447208Scael.It Er 44 ESOCKTNOSUPPORT Em "Socket type not supported" . 24520111SmckusickThe support for the socket type has not been configured into the 24620111Smckusicksystem or no implementation for it exists. 24748433Skarels.It Er 45 EOPNOTSUPP Em "Operation not supported" . 24848433SkarelsThe attempted operation is not supported for the type of object referenced. 24948433SkarelsUsually this occurs when a file descriptor refers to a file or socket 25048433Skarelsthat cannot support this operation, 25148433Skarelsfor example, trying to 25247208Scael.Em accept 25347208Scaela connection on a datagram socket. 25447208Scael.It Er 46 EPFNOSUPPORT Em "Protocol family not supported" . 25520111SmckusickThe protocol family has not been configured into the 25620111Smckusicksystem or no implementation for it exists. 25747208Scael.It Er 47 EAFNOSUPPORT Em "Address family not supported by protocol family" . 25820111SmckusickAn address incompatible with the requested protocol was used. 25947208ScaelFor example, you shouldn't necessarily expect to be able to use 26047208Scael.Tn NS 26147208Scaeladdresses with 26247208Scael.Tn ARPA 26347208ScaelInternet protocols. 26447208Scael.It Er 48 EADDRINUSE Em "Address already in use" . 26520111SmckusickOnly one usage of each address is normally permitted. 26667356Sah.sp 26747208Scael.It Er 49 EADDRNOTAVAIL Em "Cannot assign requested address" . 26820111SmckusickNormally results from an attempt to create a socket with an 26920111Smckusickaddress not on this machine. 27047208Scael.It Er 50 ENETDOWN Em "Network is down" . 27120111SmckusickA socket operation encountered a dead network. 27247208Scael.It Er 51 ENETUNREACH Em "Network is unreachable" . 27320111SmckusickA socket operation was attempted to an unreachable network. 27447208Scael.It Er 52 ENETRESET Em "Network dropped connection on reset" . 27520111SmckusickThe host you were connected to crashed and rebooted. 27647208Scael.It Er 53 ECONNABORTED Em "Software caused connection abort" . 27720111SmckusickA connection abort was caused internal to your host machine. 27847208Scael.It Er 54 ECONNRESET Em "Connection reset by peer" . 27920111SmckusickA connection was forcibly closed by a peer. This normally 28028185Skarelsresults from a loss of the connection on the remote socket 28128185Skarelsdue to a timeout or a reboot. 28247208Scael.It Er 55 ENOBUFS Em "\&No buffer space available" . 28320111SmckusickAn operation on a socket or pipe was not performed because 28428185Skarelsthe system lacked sufficient buffer space or because a queue was full. 28547208Scael.It Er 56 EISCONN Em "Socket is already connected" . 28620111SmckusickA 28747208Scael.Xr connect 28820111Smckusickrequest was made on an already connected socket; or, 28920111Smckusicka 29047208Scael.Xr sendto 29120111Smckusickor 29247208Scael.Xr sendmsg 29320111Smckusickrequest on a connected socket specified a destination 29428185Skarelswhen already connected. 29547208Scael.It Er 57 ENOTCONN Em "Socket is not connected" . 29620111SmckusickAn request to send or receive data was disallowed because 29765100Smckusickthe socket was not connected and (when sending on a datagram socket) 29828185Skarelsno address was supplied. 29947208Scael.It Er 58 ESHUTDOWN Em "Cannot send after socket shutdown" . 30020111SmckusickA request to send data was disallowed because the socket 30120111Smckusickhad already been shut down with a previous 30247208Scael.Xr shutdown 2 30320111Smckusickcall. 30464890Sbostic.It Er 60 ETIMEDOUT Em "Operation timed out" . 30520111SmckusickA 30647208Scael.Xr connect 30728185Skarelsor 30847208Scael.Xr send 30920111Smckusickrequest failed because the connected party did not 31020111Smckusickproperly respond after a period of time. (The timeout 31120111Smckusickperiod is dependent on the communication protocol.) 31247208Scael.It Er 61 ECONNREFUSED Em "Connection refused" . 31320111SmckusickNo connection could be made because the target machine actively 31420111Smckusickrefused it. This usually results from trying to connect 31523809Ssechrestto a service that is inactive on the foreign host. 31647208Scael.It Er 62 ELOOP Em "Too many levels of symbolic links" . 31720111SmckusickA path name lookup involved more than 8 symbolic links. 31847208Scael.It Er 63 ENAMETOOLONG Em "File name too long" . 31947208ScaelA component of a path name exceeded 255 32047208Scael.Pq Dv MAXNAMELEN 32147208Scaelcharacters, or an entire 32247208Scaelpath name exceeded 1023 32347208Scael.Pq Dv MAXPATHLEN Ns -1 32447208Scaelcharacters. 32547208Scael.It Er 64 EHOSTDOWN Em "Host is down" . 32620112SmckusickA socket operation failed because the destination host was down. 32747208Scael.It Er 65 EHOSTUNREACH Em "No route to host" . 32820112SmckusickA socket operation was attempted to an unreachable host. 32947208Scael.It Er 66 ENOTEMPTY Em "Directory not empty" . 33047208ScaelA directory with entries other than 33147208Scael.Ql \&. 33247208Scaeland 33347208Scael.Ql \&.. 33420111Smckusickwas supplied to a remove directory or rename call. 33547208Scael.It Er 67 EPROCLIM Em "Too many processes" . 33647208Scael.It Er 68 EUSERS Em "Too many users" . 33735335SbosticThe quota system ran out of table entries. 33847208Scael.It Er 69 EDQUOT Em "Disc quota exceeded" . 33924439SmckusickA 34047208Scael.Xr write 34124439Smckusickto an ordinary file, the creation of a 34224439Smckusickdirectory or symbolic link, or the creation of a directory 34324439Smckusickentry failed because the user's quota of disk blocks was 34424439Smckusickexhausted, or the allocation of an inode for a newly 34524439Smckusickcreated file failed because the user's quota of inodes 34624439Smckusickwas exhausted. 34767356Sah.ne 1i 34847208Scael.It Er 70 ESTALE Em "Stale NFS file handle" . 34947208ScaelAn attempt was made to access an open file (on an 35047208Scael.Tn NFS 35147208Scaelfilesystem) 35244763Strentwhich is now unavailable as referenced by the file descriptor. 35347208ScaelThis may indicate the file was deleted on the 35447208Scael.Tn NFS 35547208Scaelserver or some 35658263Smckusickother catastrophic event occurred. 35747208Scael.It Er 72 EBADRPC Em "RPC struct is bad" . 35847208ScaelExchange of 35947208Scael.Tn RPC 36047208Scaelinformation was unsuccessful. 36147208Scael.It Er 73 ERPCMISMATCH Em "RPC version wrong" . 36247208ScaelThe version of 36347208Scael.Tn RPC 36447208Scaelon the remote peer is not compatible with 36544763Strentthe local version. 36647208Scael.It Er 74 EPROGUNAVAIL Em "RPC prog. not avail" . 36744763StrentThe requested program is not registered on the remote host. 36847208Scael.It Er 75 EPROGMISMATCH Em "Program version wrong" . 36944763StrentThe requested version of the program is not available 37047208Scaelon the remote host 37147208Scael.Pq Tn RPC . 37247208Scael.It Er 76 EPROCUNAVAIL Em "Bad procedure for program" . 37347208ScaelAn 37447208Scael.Tn RPC 37547208Scaelcall was attempted for a procedure which doesn't exist 37644763Strentin the remote program. 37747208Scael.It Er 77 ENOLCK Em "No locks available" . 37844763StrentA system-imposed limit on the number of simultaneous file 37944763Strentlocks was reached. 38047208Scael.It Er 78 ENOSYS Em "Function not implemented" . 38144763StrentAttempted a system call that is not available on this 38244763Strentsystem. 38347208Scael.Sh DEFINITIONS 38447208Scael.Bl -tag -width Ds 38547208Scael.It Process ID . 38647208ScaelEach active process in the system is uniquely identified by a non-negative 38728185Skarelsinteger called a process ID. The range of this ID is from 0 to 30000. 38847208Scael.It Parent process ID 38928635SkjdA new process is created by a currently active process; (see 39047208Scael.Xr fork 2 ) . 39158474SmckusickThe parent process ID of a process is initially the process ID of its creator. 39258474SmckusickIf the creating process exits, 39358474Smckusickthe parent process ID of each child is set to the ID of a system process, 39458474Smckusick.Xr init . 39558474Smckusick.It Process Group 39620111SmckusickEach active process is a member of a process group that is identified by 39747208Scaela non-negative integer called the process group ID. This is the process 39828185SkarelsID of the group leader. This grouping permits the signaling of related 39920111Smckusickprocesses (see 40058263Smckusick.Xr termios 4 ) 40120111Smckusickand the job control mechanisms of 40247208Scael.Xr csh 1 . 40358263Smckusick.It Session 40458263SmckusickA session is a set of one or more process groups. 40558263SmckusickA session is created by a successful call to 40658263Smckusick.Xr setsid 2 , 40758263Smckusickwhich causes the caller to become the only member of the only process 40858263Smckusickgroup in the new session. 40958474Smckusick.It Session leader 41058474SmckusickA process that has created a new session by a successful call to 41158474Smckusick.Xr setsid 2 , 41258474Smckusickis known as a session leader. 41358263SmckusickOnly a session leader may acquire a terminal as its controlling terminal (see 41458263Smckusick.Xr termios 4 ) . 41558474Smckusick.It Controlling process 41658474SmckusickA session leader with a controlling terminal is a controlling process. 41758474Smckusick.It Controlling terminal 41858474SmckusickA terminal that is associated with a session is known as the controlling 41958474Smckusickterminal for that session and its members. 42067356Sah.ne 1i 42158474Smckusick.It "Terminal Process Group ID" 42258263SmckusickA terminal may be acquired by a session leader as its controlling terminal. 42358263SmckusickOnce a terminal is associated with a session, any of the process groups 42458263Smckusickwithin the session may be placed into the foreground by setting 42558263Smckusickthe terminal process group ID to the ID of the process group. 42658263SmckusickThis facility is used 42720111Smckusickto arbitrate between multiple jobs contending for the same terminal; 42828635Skjd(see 42947208Scael.Xr csh 1 43020110Smckusickand 43147208Scael.Xr tty 4 ) . 43258474Smckusick.It "Orphaned Process Group" 43358474SmckusickA process group is considered to be 43458474Smckusick.Em orphaned 43558474Smckusickif it is not under the control of a job control shell. 43658474SmckusickMore precisely, a process group is orphaned 43758474Smckusickwhen none of its members has a parent process that is in the same session 43858474Smckusickas the group, 43958474Smckusickbut is in a different process group. 44058474SmckusickNote that when a process exits, the parent process for its children 44158474Smckusickis changed to be 44258474Smckusick.Xr init , 44358474Smckusickwhich is in a separate session. 44458474SmckusickNot all members of an orphaned process group are necessarily orphaned 44558474Smckusickprocesses (those whose creating process has exited). 44658474SmckusickThe process group of a session leader is orphaned by definition. 44750486Scael.It "Real User ID and Real Group ID" 44820111SmckusickEach user on the system is identified by a positive integer 44920111Smckusicktermed the real user ID. 45047208Scael.Pp 45120111SmckusickEach user is also a member of one or more groups. 45220111SmckusickOne of these groups is distinguished from others and 45320111Smckusickused in implementing accounting facilities. The positive 45420111Smckusickinteger corresponding to this distinguished group is termed 45520111Smckusickthe real group ID. 45647208Scael.Pp 45720111SmckusickAll processes have a real user ID and real group ID. 45820111SmckusickThese are initialized from the equivalent attributes 45923809Ssechrestof the process that created it. 46058263Smckusick.It "Effective User Id, Effective Group Id, and Group Access List" 46158263SmckusickAccess to system resources is governed by two values: 46258263Smckusickthe effective user ID, and the group access list. 46358263SmckusickThe first member of the group access list is also known as the 46458263Smckusickeffective group ID. 46558263Smckusick(In POSIX.1, the group access list is known as the set of supplementary 46658263Smckusickgroup IDs, and it is unspecified whether the effective group ID is 46758263Smckusicka member of the list.) 46847208Scael.Pp 46920111SmckusickThe effective user ID and effective group ID are initially the 47020111Smckusickprocess's real user ID and real group ID respectively. Either 47120111Smckusickmay be modified through execution of a set-user-ID or set-group-ID 47228635Skjdfile (possibly by one its ancestors) (see 47347208Scael.Xr execve 2 ) . 47458263SmckusickBy convention, the effective group ID (the first member of the group access 47558263Smckusicklist) is duplicated, so that the execution of a set-group-ID program 47658263Smckusickdoes not result in the loss of the original (real) group ID. 47747208Scael.Pp 47858474SmckusickThe group access list is a set of group IDs 47920111Smckusickused only in determining resource accessibility. Access checks 48020111Smckusickare performed as described below in ``File Access Permissions''. 48158263Smckusick.It "Saved Set User ID and Saved Set Group ID" 48258263SmckusickWhen a process executes a new file, the effective user ID is set 48358263Smckusickto the owner of the file if the file is set-user-ID, and the effective 48458263Smckusickgroup ID (first element of the group access list) is set to the group 48558263Smckusickof the file if the file is set-group-ID. 48658263SmckusickThe effective user ID of the process is then recorded as the saved set-user-ID, 48758263Smckusickand the effective group ID of the process is recorded as the saved set-group-ID. 48858263SmckusickThese values may be used to regain those values as the effective user 48958263Smckusickor group ID after reverting to the real ID (see 49058263Smckusick.Xr setuid 2 ) . 49158263Smckusick(In POSIX.1, the saved set-user-ID and saved set-group-ID are optional, 49258263Smckusickand are used in setuid and setgid, but this does not work as desired 49358263Smckusickfor the super-user.) 49447208Scael.It Super-user 49520111SmckusickA process is recognized as a 49647208Scael.Em super-user 49720111Smckusickprocess and is granted special privileges if its effective user ID is 0. 49867356Sah.ne 1i 49947208Scael.It Special Processes 50058474SmckusickThe processes with process IDs of 0, 1, and 2 are special. 50120111SmckusickProcess 0 is the scheduler. Process 1 is the initialization process 50247208Scael.Xr init , 50320111Smckusickand is the ancestor of every other process in the system. 50420111SmckusickIt is used to control the process structure. 50520111SmckusickProcess 2 is the paging daemon. 50647208Scael.It Descriptor 50720111SmckusickAn integer assigned by the system when a file is referenced 50820111Smckusickby 50947208Scael.Xr open 2 51028185Skarelsor 51147208Scael.Xr dup 2 , 51228185Skarelsor when a socket is created by 51347208Scael.Xr pipe 2 , 51447208Scael.Xr socket 2 51520111Smckusickor 51647208Scael.Xr socketpair 2 , 51720111Smckusickwhich uniquely identifies an access path to that file or socket from 51820111Smckusicka given process or any of its children. 51947208Scael.It File Name 52047208ScaelNames consisting of up to 255 52147208Scael.Pq Dv MAXNAMELEN 52247208Scaelcharacters may be used to name 52320111Smckusickan ordinary file, special file, or directory. 52447208Scael.Pp 52547208ScaelThese characters may be selected from the set of all 52647208Scael.Tn ASCII 52747208Scaelcharacter 52847208Scaelexcluding 0 (NUL) and the 52947208Scael.Tn ASCII 53047208Scaelcode for 53147208Scael.Ql \&/ 53247208Scael(slash). (The parity bit, 53347208Scaelbit 7, must be 0.) 53447208Scael.Pp 53547208ScaelNote that it is generally unwise to use 53647208Scael.Ql \&* , 53747208Scael.Ql \&? , 53847208Scael.Ql \&[ 53947208Scaelor 54047208Scael.Ql \&] 54147208Scaelas part of 54220111Smckusickfile names because of the special meaning attached to these characters 54320111Smckusickby the shell. 54447208Scael.It Path Name 54550486ScaelA path name is a 54650486Scael.Tn NUL Ns -terminated 54750486Scaelcharacter string starting with an 54847208Scaeloptional slash 54947208Scael.Ql \&/ , 55047208Scaelfollowed by zero or more directory names separated 55120111Smckusickby slashes, optionally followed by a file name. 55247208ScaelThe total length of a path name must be less than 1024 55347208Scael.Pq Dv MAXPATHLEN 55447208Scaelcharacters. 55547208Scael.Pp 55620111SmckusickIf a path name begins with a slash, the path search begins at the 55747208Scael.Em root 55820111Smckusickdirectory. 55920111SmckusickOtherwise, the search begins from the current working directory. 56047208ScaelA slash by itself names the root directory. An empty 56120111Smckusickpathname refers to the current directory. 56247208Scael.It Directory 56323809SsechrestA directory is a special type of file that contains entries 56423809Ssechrestthat are references to other files. 56520111SmckusickDirectory entries are called links. By convention, a directory 56647208Scaelcontains at least two links, 56747208Scael.Ql \&. 56820110Smckusickand 56947208Scael.Ql \&.. , 57047208Scaelreferred to as 57147208Scael.Em dot 57247208Scaeland 57347208Scael.Em dot-dot 57420111Smckusickrespectively. Dot refers to the directory itself and 57520111Smckusickdot-dot refers to its parent directory. 57650486Scael.It "Root Directory and Current Working Directory" 57720111SmckusickEach process has associated with it a concept of a root directory 57820111Smckusickand a current working directory for the purpose of resolving path 57920111Smckusickname searches. A process's root directory need not be the root 58020111Smckusickdirectory of the root file system. 58147208Scael.It File Access Permissions 58220111SmckusickEvery file in the file system has a set of access permissions. 58320111SmckusickThese permissions are used in determining whether a process 58420111Smckusickmay perform a requested operation on the file (such as opening 58520111Smckusicka file for writing). Access permissions are established at the 58620111Smckusicktime a file is created. They may be changed at some later time 58720111Smckusickthrough the 58847208Scael.Xr chmod 2 58920111Smckusickcall. 59047208Scael.Pp 59120111SmckusickFile access is broken down according to whether a file may be: read, 59220111Smckusickwritten, or executed. Directory files use the execute 59320111Smckusickpermission to control if the directory may be searched. 59447208Scael.Pp 59520111SmckusickFile access permissions are interpreted by the system as 59620111Smckusickthey apply to three different classes of users: the owner 59720111Smckusickof the file, those users in the file's group, anyone else. 59820111SmckusickEvery file has an independent set of access permissions for 59920111Smckusickeach of these classes. When an access check is made, the system 60020111Smckusickdecides if permission should be granted by checking the access 60120111Smckusickinformation applicable to the caller. 60247208Scael.Pp 60320111SmckusickRead, write, and execute/search permissions on 60420111Smckusicka file are granted to a process if: 60547208Scael.Pp 60647208ScaelThe process's effective user ID is that of the super-user. (Note: 60747208Scaeleven the super-user cannot execute a non-executable file.) 60847208Scael.Pp 60920111SmckusickThe process's effective user ID matches the user ID of the owner 61020111Smckusickof the file and the owner permissions allow the access. 61147208Scael.Pp 61220111SmckusickThe process's effective user ID does not match the user ID of the 61320111Smckusickowner of the file, and either the process's effective 61420111Smckusickgroup ID matches the group ID 61520111Smckusickof the file, or the group ID of the file is in 61620111Smckusickthe process's group access list, 61720111Smckusickand the group permissions allow the access. 61847208Scael.Pp 61920111SmckusickNeither the effective user ID nor effective group ID 62020111Smckusickand group access list of the process 62120111Smckusickmatch the corresponding user ID and group ID of the file, 62220111Smckusickbut the permissions for ``other users'' allow access. 62347208Scael.Pp 62420111SmckusickOtherwise, permission is denied. 62547208Scael.It Sockets and Address Families 62647208Scael.Pp 62720111SmckusickA socket is an endpoint for communication between processes. 62820111SmckusickEach socket has queues for sending and receiving data. 62947208Scael.Pp 63020111SmckusickSockets are typed according to their communications properties. 63120111SmckusickThese properties include whether messages sent and received 63220111Smckusickat a socket require the name of the partner, whether communication 63320111Smckusickis reliable, the format used in naming message recipients, etc. 63447208Scael.Pp 63520111SmckusickEach instance of the system supports some 63620111Smckusickcollection of socket types; consult 63747208Scael.Xr socket 2 63820111Smckusickfor more information about the types available and 63920111Smckusicktheir properties. 64047208Scael.Pp 64120111SmckusickEach instance of the system supports some number of sets of 64220111Smckusickcommunications protocols. Each protocol set supports addresses 64320111Smckusickof a certain format. An Address Family is the set of addresses 64420111Smckusickfor a specific group of protocols. Each socket has an address 64520111Smckusickchosen from the address family in which the socket was created. 64647208Scael.Sh SEE ALSO 647*68456Smckusick.Xr intro 3 , 648*68456Smckusick.Xr perror 3 649