161181Sbostic.\" Copyright (c) 1993, 1980198319861991 261181Sbostic.\" The Regents of the University of California. All rights reserved. 320110Smckusick.\" 447208Scael.\" %sccs.include.redist.man% 520110Smckusick.\" 6*64890Sbostic.\" @(#)intro.2 8.2 (Berkeley) 11/16/93 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. 5347208Scael.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. 7347208ScaelThis error 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 8147208Scaelis loaded 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). 9847208Scael.It Er 10 ECHILD Em "\&No child processes" . 9947208ScaelA 10047208Scael.Xr wait 10147208Scaelor 10247208Scael.Xr waitpid 10347208Scaelfunction was executed by a process that had no existing or unwaited-for 10447208Scaelchild processes. 10547208Scael.It Er 11 EDEADLK Em "Resource deadlock avoided" . 10644763StrentAn attempt was made to lock a system resource that 10744763Strentwould have resulted in a deadlock situation. 10858263Smckusick.It Er 12 ENOMEM Em "Cannot allocate memory" . 10947208ScaelThe new process image required more memory than was allowed by the hardware 11047208Scaelor by system-imposed memory management constraints. 11147208ScaelA lack of swap space is normally temporary; however, 11247208Scaela lack of core is not. 11328185SkarelsSoft limits may be increased to their corresponding hard limits. 11447208Scael.It Er 13 EACCES Em "Permission denied" . 11520110SmckusickAn attempt was made to access a file in a way forbidden 11647208Scaelby its file access permissions. 11747208Scael.It Er 14 EFAULT Em "Bad address" . 11847208ScaelThe system detected an invalid address in attempting to 11947208Scaeluse an argument of a call. 12047208Scael.It Er 15 ENOTBLK Em "Not a block device" . 12147208ScaelA block device operation was attempted on a non-block device or file. 12247208Scael.It Er 16 EBUSY Em "Resource busy" . 12347208ScaelAn attempt to use a system resource which was in use at the time 12447208Scaelin a manner which would have conflicted with the request. 12547208Scael.It Er 17 EEXIST Em "File exists" . 12620110SmckusickAn existing file was mentioned in an inappropriate context, 12747208Scaelfor instance, as the new link name in a 12847208Scael.Xr link 12947208Scaelfunction. 13047208Scael.It Er 18 EXDEV Em "Improper link" . 13147208ScaelA hard link to a file on another file system 13220110Smckusickwas attempted. 13347208Scael.It Er 19 ENODEV Em "Operation not supported by device" . 13420110SmckusickAn attempt was made to apply an inappropriate 13547208Scaelfunction to a device, 13647208Scaelfor example, 13747208Scaeltrying to read a write-only device such as a printer. 13847208Scael.It Er 20 ENOTDIR Em "Not a directory" . 13947208ScaelA component of the specified pathname existed, but it was 14047208Scaelnot a directory, when a directory was expected. 14147208Scael.It Er 21 EISDIR Em "Is a directory" . 14247208ScaelAn attempt was made to open a directory with write mode specified. 14347208Scael.It Er 22 EINVAL Em "Invalid argument" . 14447208ScaelSome invalid argument was supplied. (For example, 14547208Scaelspecifying an undefined signal to a 14647208Scael.Xr signal 14747208Scaelor 14847208Scael.Xr kill 14947208Scaelfunction). 15047208Scael.It Er 23 ENFILE Em "Too many open files in system" . 15147208ScaelMaximum number of file descriptors allowable on the system 15247208Scaelhas been reached and a requests for an open cannot be satisfied 15347208Scaeluntil at least one has been closed. 15447208Scael.It Er 24 EMFILE Em "Too many open files" . 15547208Scael<As released, the limit on the number of 15647208Scaelopen files per process is 64.> 15747208Scael.Xr Getdtablesize 2 15828185Skarelswill obtain the current limit. 15947208Scael.It Er 25 ENOTTY Em "Inappropriate ioctl for device" . 16047208ScaelA control function (see 16147208Scael.Xr ioctl 2 ) 16247208Scaelwas attempted for a file or 16347208Scaelspecial device for which the operation was inappropriate. 16447208Scael.It Er 26 ETXTBSY Em "Text file busy" . 16547208ScaelThe new process was a pure procedure (shared text) file 16647208Scaelwhich was open for writing by another process, or 16747208Scaelthe pure procedure file was being executed an 16847208Scael.Xr open 16947208Scaelcall requested write access. 17047208Scael.It Er 27 EFBIG Em "File too large" . 17120110SmckusickThe size of a file exceeded the maximum (about 17228185Skarels.if t 2\u\s-231\s+2\d 17328185Skarels.if n 2.1E9 17420110Smckusickbytes). 17547208Scael.It Er 28 ENOSPC Em "Device out of space" . 17624439SmckusickA 17747208Scael.Xr write 17824439Smckusickto an ordinary file, the creation of a 17924439Smckusickdirectory or symbolic link, or the creation of a directory 18024439Smckusickentry failed because no more disk blocks are available 18124439Smckusickon the file system, or the allocation of an inode for a newly 18224439Smckusickcreated file failed because no more inodes are available 18324439Smckusickon the file system. 18447208Scael.It Er 29 ESPIPE Em "Illegal seek" . 18520110SmckusickAn 18647208Scael.Xr lseek 18747208Scaelfunction was issued on a socket, pipe or 18847208Scael.Tn FIFO . 18947208Scael.It Er 30 EROFS Em "Read-only file system" . 19047208ScaelAn attempt was made to modify a file or directory 19120110Smckusickwas made 19247208Scaelon a file system that was read-only at the time. 19347208Scael.It Er 31 EMLINK Em "Too many links" . 19447208ScaelMaximum allowable hard links to a single file has been exceeded (limit 19547208Scaelof 32767 hard links per file). 19647208Scael.It Er 32 EPIPE Em "Broken pipe" . 19747208ScaelA write on a pipe, socket or 19847208Scael.Tn FIFO 19947208Scaelfor which there is no process 20020110Smckusickto read the data. 20147208Scael.It Er 33 EDOM Em "Numerical argument out of domain" . 20247208ScaelA numerical input argument was outside the defined domain of the mathematical 20347208Scaelfunction. 20447208Scael.It Er 34 ERANGE Em "Numerical result out of range" . 20547208ScaelA numerical result of the function was to large to fit in the 20647208Scaelavailable space (perhaps exceeded precision). 20747208Scael.It Er 35 EAGAIN Em "Resource temporarily unavailable" . 20844763StrentThis is a temporary condition and later calls to the 20944763Strentsame routine may complete normally. 21047208Scael.It Er 36 EINPROGRESS Em "Operation now in progress" . 21123809SsechrestAn operation that takes a long time to complete (such as 21247208Scaela 21347208Scael.Xr connect 2 ) 21447208Scaelwas attempted on a non-blocking object (see 21547208Scael.Xr fcntl 2 ) . 21647208Scael.It Er 37 EALREADY Em "Operation already in progress" . 21723809SsechrestAn operation was attempted on a non-blocking object that already 21820111Smckusickhad an operation in progress. 21947208Scael.It Er 38 ENOTSOCK Em "Socket operation on non-socket" . 22020111SmckusickSelf-explanatory. 22147208Scael.It Er 39 EDESTADDRREQ Em "Destination address required" . 22220111SmckusickA required address was omitted from an operation on a socket. 22347208Scael.It Er 40 EMSGSIZE Em "Message too long" . 22428185SkarelsA message sent on a socket was larger than the internal message buffer 22528185Skarelsor some other network limit. 22647208Scael.It Er 41 EPROTOTYPE Em "Protocol wrong type for socket" . 22723809SsechrestA protocol was specified that does not support the semantics of the 22847208Scaelsocket type requested. For example, you cannot use the 22947208Scael.Tn ARPA 23047208ScaelInternet 23147208Scael.Tn UDP 23247208Scaelprotocol with type 23347208Scael.Dv SOCK_STREAM . 23447208Scael.It Er 42 ENOPROTOOPT Em "Protocol not available" . 23528185SkarelsA bad option or level was specified in a 23647208Scael.Xr getsockopt 2 23720111Smckusickor 23847208Scael.Xr setsockopt 2 23920111Smckusickcall. 24047208Scael.It Er 43 EPROTONOSUPPORT Em "Protocol not supported" . 24120111SmckusickThe protocol has not been configured into the 24220111Smckusicksystem or no implementation for it exists. 24347208Scael.It Er 44 ESOCKTNOSUPPORT Em "Socket type not supported" . 24420111SmckusickThe support for the socket type has not been configured into the 24520111Smckusicksystem or no implementation for it exists. 24648433Skarels.It Er 45 EOPNOTSUPP Em "Operation not supported" . 24748433SkarelsThe attempted operation is not supported for the type of object referenced. 24848433SkarelsUsually this occurs when a file descriptor refers to a file or socket 24948433Skarelsthat cannot support this operation, 25048433Skarelsfor example, trying to 25147208Scael.Em accept 25247208Scaela connection on a datagram socket. 25347208Scael.It Er 46 EPFNOSUPPORT Em "Protocol family not supported" . 25420111SmckusickThe protocol family has not been configured into the 25520111Smckusicksystem or no implementation for it exists. 25647208Scael.It Er 47 EAFNOSUPPORT Em "Address family not supported by protocol family" . 25720111SmckusickAn address incompatible with the requested protocol was used. 25847208ScaelFor example, you shouldn't necessarily expect to be able to use 25947208Scael.Tn NS 26047208Scaeladdresses with 26147208Scael.Tn ARPA 26247208ScaelInternet protocols. 26347208Scael.It Er 48 EADDRINUSE Em "Address already in use" . 26420111SmckusickOnly one usage of each address is normally permitted. 26547208Scael.It Er 49 EADDRNOTAVAIL Em "Cannot assign requested address" . 26620111SmckusickNormally results from an attempt to create a socket with an 26720111Smckusickaddress not on this machine. 26847208Scael.It Er 50 ENETDOWN Em "Network is down" . 26920111SmckusickA socket operation encountered a dead network. 27047208Scael.It Er 51 ENETUNREACH Em "Network is unreachable" . 27120111SmckusickA socket operation was attempted to an unreachable network. 27247208Scael.It Er 52 ENETRESET Em "Network dropped connection on reset" . 27320111SmckusickThe host you were connected to crashed and rebooted. 27447208Scael.It Er 53 ECONNABORTED Em "Software caused connection abort" . 27520111SmckusickA connection abort was caused internal to your host machine. 27647208Scael.It Er 54 ECONNRESET Em "Connection reset by peer" . 27720111SmckusickA connection was forcibly closed by a peer. This normally 27828185Skarelsresults from a loss of the connection on the remote socket 27928185Skarelsdue to a timeout or a reboot. 28047208Scael.It Er 55 ENOBUFS Em "\&No buffer space available" . 28120111SmckusickAn operation on a socket or pipe was not performed because 28228185Skarelsthe system lacked sufficient buffer space or because a queue was full. 28347208Scael.It Er 56 EISCONN Em "Socket is already connected" . 28420111SmckusickA 28547208Scael.Xr connect 28620111Smckusickrequest was made on an already connected socket; or, 28720111Smckusicka 28847208Scael.Xr sendto 28920111Smckusickor 29047208Scael.Xr sendmsg 29120111Smckusickrequest on a connected socket specified a destination 29228185Skarelswhen already connected. 29347208Scael.It Er 57 ENOTCONN Em "Socket is not connected" . 29420111SmckusickAn request to send or receive data was disallowed because 29528185Skarelsthe socket is not connected and (when sending on a datagram socket) 29628185Skarelsno address was supplied. 29747208Scael.It Er 58 ESHUTDOWN Em "Cannot send after socket shutdown" . 29820111SmckusickA request to send data was disallowed because the socket 29920111Smckusickhad already been shut down with a previous 30047208Scael.Xr shutdown 2 30120111Smckusickcall. 302*64890Sbostic.It Er 60 ETIMEDOUT Em "Operation timed out" . 30320111SmckusickA 30447208Scael.Xr connect 30528185Skarelsor 30647208Scael.Xr send 30720111Smckusickrequest failed because the connected party did not 30820111Smckusickproperly respond after a period of time. (The timeout 30920111Smckusickperiod is dependent on the communication protocol.) 31047208Scael.It Er 61 ECONNREFUSED Em "Connection refused" . 31120111SmckusickNo connection could be made because the target machine actively 31220111Smckusickrefused it. This usually results from trying to connect 31323809Ssechrestto a service that is inactive on the foreign host. 31447208Scael.It Er 62 ELOOP Em "Too many levels of symbolic links" . 31520111SmckusickA path name lookup involved more than 8 symbolic links. 31647208Scael.It Er 63 ENAMETOOLONG Em "File name too long" . 31747208ScaelA component of a path name exceeded 255 31847208Scael.Pq Dv MAXNAMELEN 31947208Scaelcharacters, or an entire 32047208Scaelpath name exceeded 1023 32147208Scael.Pq Dv MAXPATHLEN Ns -1 32247208Scaelcharacters. 32347208Scael.It Er 64 EHOSTDOWN Em "Host is down" . 32420112SmckusickA socket operation failed because the destination host was down. 32547208Scael.It Er 65 EHOSTUNREACH Em "No route to host" . 32620112SmckusickA socket operation was attempted to an unreachable host. 32747208Scael.It Er 66 ENOTEMPTY Em "Directory not empty" . 32847208ScaelA directory with entries other than 32947208Scael.Ql \&. 33047208Scaeland 33147208Scael.Ql \&.. 33220111Smckusickwas supplied to a remove directory or rename call. 33347208Scael.It Er 67 EPROCLIM Em "Too many processes" . 33447208Scael.It Er 68 EUSERS Em "Too many users" . 33535335SbosticThe quota system ran out of table entries. 33647208Scael.It Er 69 EDQUOT Em "Disc quota exceeded" . 33724439SmckusickA 33847208Scael.Xr write 33924439Smckusickto an ordinary file, the creation of a 34024439Smckusickdirectory or symbolic link, or the creation of a directory 34124439Smckusickentry failed because the user's quota of disk blocks was 34224439Smckusickexhausted, or the allocation of an inode for a newly 34324439Smckusickcreated file failed because the user's quota of inodes 34424439Smckusickwas exhausted. 34547208Scael.It Er 70 ESTALE Em "Stale NFS file handle" . 34647208ScaelAn attempt was made to access an open file (on an 34747208Scael.Tn NFS 34847208Scaelfilesystem) 34944763Strentwhich is now unavailable as referenced by the file descriptor. 35047208ScaelThis may indicate the file was deleted on the 35147208Scael.Tn NFS 35247208Scaelserver or some 35358263Smckusickother catastrophic event occurred. 35447208Scael.It Er 72 EBADRPC Em "RPC struct is bad" . 35547208ScaelExchange of 35647208Scael.Tn RPC 35747208Scaelinformation was unsuccessful. 35847208Scael.It Er 73 ERPCMISMATCH Em "RPC version wrong" . 35947208ScaelThe version of 36047208Scael.Tn RPC 36147208Scaelon the remote peer is not compatible with 36244763Strentthe local version. 36347208Scael.It Er 74 EPROGUNAVAIL Em "RPC prog. not avail" . 36444763StrentThe requested program is not registered on the remote host. 36547208Scael.It Er 75 EPROGMISMATCH Em "Program version wrong" . 36644763StrentThe requested version of the program is not available 36747208Scaelon the remote host 36847208Scael.Pq Tn RPC . 36947208Scael.It Er 76 EPROCUNAVAIL Em "Bad procedure for program" . 37047208ScaelAn 37147208Scael.Tn RPC 37247208Scaelcall was attempted for a procedure which doesn't exist 37344763Strentin the remote program. 37447208Scael.It Er 77 ENOLCK Em "No locks available" . 37544763StrentA system-imposed limit on the number of simultaneous file 37644763Strentlocks was reached. 37747208Scael.It Er 78 ENOSYS Em "Function not implemented" . 37844763StrentAttempted a system call that is not available on this 37944763Strentsystem. 38047208Scael.Sh DEFINITIONS 38147208Scael.Bl -tag -width Ds 38247208Scael.It Process ID . 38347208ScaelEach active process in the system is uniquely identified by a non-negative 38428185Skarelsinteger called a process ID. The range of this ID is from 0 to 30000. 38547208Scael.It Parent process ID 38628635SkjdA new process is created by a currently active process; (see 38747208Scael.Xr fork 2 ) . 38858474SmckusickThe parent process ID of a process is initially the process ID of its creator. 38958474SmckusickIf the creating process exits, 39058474Smckusickthe parent process ID of each child is set to the ID of a system process, 39158474Smckusick.Xr init . 39258474Smckusick.It Process Group 39320111SmckusickEach active process is a member of a process group that is identified by 39447208Scaela non-negative integer called the process group ID. This is the process 39528185SkarelsID of the group leader. This grouping permits the signaling of related 39620111Smckusickprocesses (see 39758263Smckusick.Xr termios 4 ) 39820111Smckusickand the job control mechanisms of 39947208Scael.Xr csh 1 . 40058263Smckusick.It Session 40158263SmckusickA session is a set of one or more process groups. 40258263SmckusickA session is created by a successful call to 40358263Smckusick.Xr setsid 2 , 40458263Smckusickwhich causes the caller to become the only member of the only process 40558263Smckusickgroup in the new session. 40658474Smckusick.It Session leader 40758474SmckusickA process that has created a new session by a successful call to 40858474Smckusick.Xr setsid 2 , 40958474Smckusickis known as a session leader. 41058263SmckusickOnly a session leader may acquire a terminal as its controlling terminal (see 41158263Smckusick.Xr termios 4 ) . 41258474Smckusick.It Controlling process 41358474SmckusickA session leader with a controlling terminal is a controlling process. 41458474Smckusick.It Controlling terminal 41558474SmckusickA terminal that is associated with a session is known as the controlling 41658474Smckusickterminal for that session and its members. 41758474Smckusick.It "Terminal Process Group ID" 41858263SmckusickA terminal may be acquired by a session leader as its controlling terminal. 41958263SmckusickOnce a terminal is associated with a session, any of the process groups 42058263Smckusickwithin the session may be placed into the foreground by setting 42158263Smckusickthe terminal process group ID to the ID of the process group. 42258263SmckusickThis facility is used 42320111Smckusickto arbitrate between multiple jobs contending for the same terminal; 42428635Skjd(see 42547208Scael.Xr csh 1 42620110Smckusickand 42747208Scael.Xr tty 4 ) . 42858474Smckusick.It "Orphaned Process Group" 42958474SmckusickA process group is considered to be 43058474Smckusick.Em orphaned 43158474Smckusickif it is not under the control of a job control shell. 43258474SmckusickMore precisely, a process group is orphaned 43358474Smckusickwhen none of its members has a parent process that is in the same session 43458474Smckusickas the group, 43558474Smckusickbut is in a different process group. 43658474SmckusickNote that when a process exits, the parent process for its children 43758474Smckusickis changed to be 43858474Smckusick.Xr init , 43958474Smckusickwhich is in a separate session. 44058474SmckusickNot all members of an orphaned process group are necessarily orphaned 44158474Smckusickprocesses (those whose creating process has exited). 44258474SmckusickThe process group of a session leader is orphaned by definition. 44350486Scael.It "Real User ID and Real Group ID" 44420111SmckusickEach user on the system is identified by a positive integer 44520111Smckusicktermed the real user ID. 44647208Scael.Pp 44720111SmckusickEach user is also a member of one or more groups. 44820111SmckusickOne of these groups is distinguished from others and 44920111Smckusickused in implementing accounting facilities. The positive 45020111Smckusickinteger corresponding to this distinguished group is termed 45120111Smckusickthe real group ID. 45247208Scael.Pp 45320111SmckusickAll processes have a real user ID and real group ID. 45420111SmckusickThese are initialized from the equivalent attributes 45523809Ssechrestof the process that created it. 45658263Smckusick.It "Effective User Id, Effective Group Id, and Group Access List" 45758263SmckusickAccess to system resources is governed by two values: 45858263Smckusickthe effective user ID, and the group access list. 45958263SmckusickThe first member of the group access list is also known as the 46058263Smckusickeffective group ID. 46158263Smckusick(In POSIX.1, the group access list is known as the set of supplementary 46258263Smckusickgroup IDs, and it is unspecified whether the effective group ID is 46358263Smckusicka member of the list.) 46447208Scael.Pp 46520111SmckusickThe effective user ID and effective group ID are initially the 46620111Smckusickprocess's real user ID and real group ID respectively. Either 46720111Smckusickmay be modified through execution of a set-user-ID or set-group-ID 46828635Skjdfile (possibly by one its ancestors) (see 46947208Scael.Xr execve 2 ) . 47058263SmckusickBy convention, the effective group ID (the first member of the group access 47158263Smckusicklist) is duplicated, so that the execution of a set-group-ID program 47258263Smckusickdoes not result in the loss of the original (real) group ID. 47347208Scael.Pp 47458474SmckusickThe group access list is a set of group IDs 47520111Smckusickused only in determining resource accessibility. Access checks 47620111Smckusickare performed as described below in ``File Access Permissions''. 47758263Smckusick.It "Saved Set User ID and Saved Set Group ID" 47858263SmckusickWhen a process executes a new file, the effective user ID is set 47958263Smckusickto the owner of the file if the file is set-user-ID, and the effective 48058263Smckusickgroup ID (first element of the group access list) is set to the group 48158263Smckusickof the file if the file is set-group-ID. 48258263SmckusickThe effective user ID of the process is then recorded as the saved set-user-ID, 48358263Smckusickand the effective group ID of the process is recorded as the saved set-group-ID. 48458263SmckusickThese values may be used to regain those values as the effective user 48558263Smckusickor group ID after reverting to the real ID (see 48658263Smckusick.Xr setuid 2 ) . 48758263Smckusick(In POSIX.1, the saved set-user-ID and saved set-group-ID are optional, 48858263Smckusickand are used in setuid and setgid, but this does not work as desired 48958263Smckusickfor the super-user.) 49047208Scael.It Super-user 49120111SmckusickA process is recognized as a 49247208Scael.Em super-user 49320111Smckusickprocess and is granted special privileges if its effective user ID is 0. 49447208Scael.It Special Processes 49558474SmckusickThe processes with process IDs of 0, 1, and 2 are special. 49620111SmckusickProcess 0 is the scheduler. Process 1 is the initialization process 49747208Scael.Xr init , 49820111Smckusickand is the ancestor of every other process in the system. 49920111SmckusickIt is used to control the process structure. 50020111SmckusickProcess 2 is the paging daemon. 50147208Scael.It Descriptor 50220111SmckusickAn integer assigned by the system when a file is referenced 50320111Smckusickby 50447208Scael.Xr open 2 50528185Skarelsor 50647208Scael.Xr dup 2 , 50728185Skarelsor when a socket is created by 50847208Scael.Xr pipe 2 , 50947208Scael.Xr socket 2 51020111Smckusickor 51147208Scael.Xr socketpair 2 , 51220111Smckusickwhich uniquely identifies an access path to that file or socket from 51320111Smckusicka given process or any of its children. 51447208Scael.It File Name 51547208ScaelNames consisting of up to 255 51647208Scael.Pq Dv MAXNAMELEN 51747208Scaelcharacters may be used to name 51820111Smckusickan ordinary file, special file, or directory. 51947208Scael.Pp 52047208ScaelThese characters may be selected from the set of all 52147208Scael.Tn ASCII 52247208Scaelcharacter 52347208Scaelexcluding 0 (NUL) and the 52447208Scael.Tn ASCII 52547208Scaelcode for 52647208Scael.Ql \&/ 52747208Scael(slash). (The parity bit, 52847208Scaelbit 7, must be 0.) 52947208Scael.Pp 53047208ScaelNote that it is generally unwise to use 53147208Scael.Ql \&* , 53247208Scael.Ql \&? , 53347208Scael.Ql \&[ 53447208Scaelor 53547208Scael.Ql \&] 53647208Scaelas part of 53720111Smckusickfile names because of the special meaning attached to these characters 53820111Smckusickby the shell. 53947208Scael.It Path Name 54050486ScaelA path name is a 54150486Scael.Tn NUL Ns -terminated 54250486Scaelcharacter string starting with an 54347208Scaeloptional slash 54447208Scael.Ql \&/ , 54547208Scaelfollowed by zero or more directory names separated 54620111Smckusickby slashes, optionally followed by a file name. 54747208ScaelThe total length of a path name must be less than 1024 54847208Scael.Pq Dv MAXPATHLEN 54947208Scaelcharacters. 55047208Scael.Pp 55120111SmckusickIf a path name begins with a slash, the path search begins at the 55247208Scael.Em root 55320111Smckusickdirectory. 55420111SmckusickOtherwise, the search begins from the current working directory. 55547208ScaelA slash by itself names the root directory. An empty 55620111Smckusickpathname refers to the current directory. 55747208Scael.It Directory 55823809SsechrestA directory is a special type of file that contains entries 55923809Ssechrestthat are references to other files. 56020111SmckusickDirectory entries are called links. By convention, a directory 56147208Scaelcontains at least two links, 56247208Scael.Ql \&. 56320110Smckusickand 56447208Scael.Ql \&.. , 56547208Scaelreferred to as 56647208Scael.Em dot 56747208Scaeland 56847208Scael.Em dot-dot 56920111Smckusickrespectively. Dot refers to the directory itself and 57020111Smckusickdot-dot refers to its parent directory. 57150486Scael.It "Root Directory and Current Working Directory" 57220111SmckusickEach process has associated with it a concept of a root directory 57320111Smckusickand a current working directory for the purpose of resolving path 57420111Smckusickname searches. A process's root directory need not be the root 57520111Smckusickdirectory of the root file system. 57647208Scael.It File Access Permissions 57720111SmckusickEvery file in the file system has a set of access permissions. 57820111SmckusickThese permissions are used in determining whether a process 57920111Smckusickmay perform a requested operation on the file (such as opening 58020111Smckusicka file for writing). Access permissions are established at the 58120111Smckusicktime a file is created. They may be changed at some later time 58220111Smckusickthrough the 58347208Scael.Xr chmod 2 58420111Smckusickcall. 58547208Scael.Pp 58620111SmckusickFile access is broken down according to whether a file may be: read, 58720111Smckusickwritten, or executed. Directory files use the execute 58820111Smckusickpermission to control if the directory may be searched. 58947208Scael.Pp 59020111SmckusickFile access permissions are interpreted by the system as 59120111Smckusickthey apply to three different classes of users: the owner 59220111Smckusickof the file, those users in the file's group, anyone else. 59320111SmckusickEvery file has an independent set of access permissions for 59420111Smckusickeach of these classes. When an access check is made, the system 59520111Smckusickdecides if permission should be granted by checking the access 59620111Smckusickinformation applicable to the caller. 59747208Scael.Pp 59820111SmckusickRead, write, and execute/search permissions on 59920111Smckusicka file are granted to a process if: 60047208Scael.Pp 60147208ScaelThe process's effective user ID is that of the super-user. (Note: 60247208Scaeleven the super-user cannot execute a non-executable file.) 60347208Scael.Pp 60420111SmckusickThe process's effective user ID matches the user ID of the owner 60520111Smckusickof the file and the owner permissions allow the access. 60647208Scael.Pp 60720111SmckusickThe process's effective user ID does not match the user ID of the 60820111Smckusickowner of the file, and either the process's effective 60920111Smckusickgroup ID matches the group ID 61020111Smckusickof the file, or the group ID of the file is in 61120111Smckusickthe process's group access list, 61220111Smckusickand the group permissions allow the access. 61347208Scael.Pp 61420111SmckusickNeither the effective user ID nor effective group ID 61520111Smckusickand group access list of the process 61620111Smckusickmatch the corresponding user ID and group ID of the file, 61720111Smckusickbut the permissions for ``other users'' allow access. 61847208Scael.Pp 61920111SmckusickOtherwise, permission is denied. 62047208Scael.It Sockets and Address Families 62147208Scael.Pp 62220111SmckusickA socket is an endpoint for communication between processes. 62320111SmckusickEach socket has queues for sending and receiving data. 62447208Scael.Pp 62520111SmckusickSockets are typed according to their communications properties. 62620111SmckusickThese properties include whether messages sent and received 62720111Smckusickat a socket require the name of the partner, whether communication 62820111Smckusickis reliable, the format used in naming message recipients, etc. 62947208Scael.Pp 63020111SmckusickEach instance of the system supports some 63120111Smckusickcollection of socket types; consult 63247208Scael.Xr socket 2 63320111Smckusickfor more information about the types available and 63420111Smckusicktheir properties. 63547208Scael.Pp 63620111SmckusickEach instance of the system supports some number of sets of 63720111Smckusickcommunications protocols. Each protocol set supports addresses 63820111Smckusickof a certain format. An Address Family is the set of addresses 63920111Smckusickfor a specific group of protocols. Each socket has an address 64020111Smckusickchosen from the address family in which the socket was created. 64147208Scael.Sh SEE ALSO 64220111Smckusickintro(3), perror(3) 643