INTRO(2) INTRO(2) NAME intro - introduction to system calls and error numbers SYNOPSIS #include <errno.h> #include <limits.h> DESCRIPTION This section describes all of the system calls. Most of these calls have one or more error returns. An error condition is indicated by an otherwise impossible returned value. This is almost always -1 or the NULL pointer; the individual descriptions specify the details. An error number is also made available in the external variable errno. errno is not cleared on successful calls, so it should be tested only after an error has been indicated. Many of these errors are caused by certain system or user limits being exceeded. In the individual manual pages, these limits are enclosed in braces (i.e. {OPEN_MAX}). The section LIMITS defines these limits, where and how they are configured, and whether they are alterable. Each system call description attempts to list all possible error numbers. The following is a complete list of the error numbers and their names as defined in <errno.h>. 1 EPERM Operation not permitted Typically this error indicates an attempt to modify a file in some way forbidden except to its owner or super-user. It is also returned for attempts by ordinary users to do things allowed only to the super-user. A special case of this involves setuid/setgid shell scripts and a kernel that is configured with a non-zero value for nosuidshells (the shipped default). The kernel returns EPERM when a non-superuser attempts to execute such a shell script with a uid or gid which is different than the user's effective uid/gid. The kernel also returns EPERM if it has been configured with a non-zero value for restricted_chown . Only the super-user can change the owner of the file, because if users were able to give files away, they could defeat the file space accounting procedures. The owner of the file may change the group ownership only to those groups of which he is a member. Another case where the kernel may return EPERM is when a non-superuser tries to execute a setuid file which belongs to some other user and the file system in which the file resides has been mounted with the nosuid option. 2 ENOENT No such file or directory This error occurs when a file name is specified and the file should exist but doesn't, or when one of the directories in a path name does not exist. 3 ESRCH No such process No process can be found corresponding to that specified by pid in kill(2), blockproc(2), or ptrace(2). 4 EINTR Interrupted function call An asynchronous signal (such as interrupt or quit), which the user has elected to catch, occurred during the execution of an interruptible function. If execution is resumed after processing the signal, it will appear as if the interrupted system call returned this error condition [see section on interruptibility]. 5 EIO I/O error Some physical I/O error has occurred. This error may in some cases occur on a call following the one to which it actually applies. 6 ENXIO No such device or address I/O on a special file refers to a subdevice which does not exist, or beyond the limits of the device. It may also occur when, for example, a tape drive is not on-line or no disk pack is loaded on a drive. 7 E2BIG Arg list too long An argument list longer than {ARG_MAX} bytes is presented to a member of the exec(2) family. 8 ENOEXEC Exec format error A request is made to execute a file which, although it has the appropriate permissions, does not start with a valid magic number [see a.out(4)]. 9 EBADF Bad file number Either a file descriptor refers to no open file, or a read(2) [respectively, write(2)] request is made to a file which is open only for writing (respectively, reading). 10 ECHILD No child processes A wait or waitpid function was executed by a process that had no existing or unwaited-for child processes. 11 EAGAIN Resource temporarily unavailable 1) A fork or sproc failed because the maximum number of processes system wide {NPROC} was exceeded or the user exceeded their limit on the number of child processes {CHILD_MAX}. 2) A system call failed because of insufficient memory or swap space. Later calls to the same routine may complete normally. 3) Some read system calls-- involving empty streams or locked files/records--with the O_NDELAY flag set may return this error. See read(2). 4) An operation which would cause a process to block was attempted on an object in non- blocking mode [see ioctl(2)]. 5) A file system operation was unable to complete due to a locked file or record (see fcntl(2)]. 11 EWOULDBLOCK Operation would block This is a synonym for EAGAIN. 12 ENOMEM Not enough space During an exec(2), brk(2), or sbrk(2), a process exceeds its maximum allowable size {PROCSIZE_MAX}. This may also be returned by device drivers if they cannot dynamically allocate enough space. 13 EACCES Permission denied An attempt was made to access a file in a way forbidden by the protection system. 14 EFAULT Bad address The system encountered a hardware fault in attempting to use an argument of a system call. 15 ENOTBLK Block device required A non-block file was mentioned where a block device was required, (e.g., in a call to the mount(2) routine). 16 EBUSY Resource busy An attempt was made to mount a device that was already mounted or an attempt was made to dismount a device on which there is an active file (open file, current directory, mounted-on file, active text segment). It will also occur if an attempt is made to enable accounting when it is already enabled. The device or resource is currently unavailable. 17 EEXIST File exists An existing file was mentioned in an inappropriate context, (e.g., call to the link(2) routine). 18 EXDEV Improper link A link to a file on another file system was attempted. 19 ENODEV No such device An attempt was made to apply an inappropriate system call to a device; e.g., read a write-only device. 20 ENOTDIR Not a directory A non-directory was specified where a directory is required, (e.g., in a path prefix or as an argument to the chdir(2) routine). 21 EISDIR Is a directory An attempt was made to write on a directory. 22 EINVAL Invalid argument Some invalid argument (e.g., dismounting a non-mounted device; mentioning an undefined signal in signal(2) or kill(2); reading or writing a file for which lseek(2) has generated a negative pointer). Also set by the math functions described in the (3M) entries of this manual. 23 ENFILE Too many open files in system The system file table is full (has exceeded {NFILE_MAX} entries), and temporarily no more opens can be accepted. 24 EMFILE Too many open files in a process No process may have more than {OPEN_MAX} descriptors open at a time. Or the maximum number of shared memory segments {SHMAT_MAX} was exceeded. 25 ENOTTY Inappropriate I/O control operation An attempt was made to ioctl(2) a file that is not a special character device. 26 ETXTBSY Text file busy An attempt was made to execute a pure-procedure program that is currently open for writing. Also an attempt to open for writing or to remove a pure-procedure program that is being executed. This error is no longer returned, and the actions mentioned above are now permitted. 27 EFBIG File too large The size of a file exceeded the per process maximum file size {FILESIZE_MAX}, or the file has more than the maximum number of direct and indirect extents (usually indicates an extremely fragmented filesystem; see fsr(1m) for a method to fix this). 28 ENOSPC No space left on device During a write(2) to an ordinary file, there is no free space left on the device. 29 ESPIPE Illegal seek An lseek(2) was issued to a pipe or FIFO. 30 EROFS Read-only file system An attempt to modify a file or directory was made on a device mounted read-only. 31 EMLINK Too many links An attempt to make more than the maximum number of links {LINK_MAX} to a file. 32 EPIPE Broken pipe A write on a pipe or FIFO for which there is no process to read the data. 33 EDOM Domain error The argument of a function in the math package (3M) or other library functions is out of the domain of the function. 34 ERANGE Result too large The value of a function in the math package (3M) is not representable within machine precision, or a size specified is not large enough. 35 ENOMSG No message of desired type An attempt was made to receive a message of a type that does not exist on the specified message queue [see msgop(2)]. 36 EIDRM Identifier removed This error is returned to processes that resume execution due to the removal of an identifier from the file system's name space [see msgctl(2), semctl(2), and shmctl(2)]. 37-44 Reserved numbers 45 EDEADLK Resource deadlock avoided An attempt was made to lock a system resource that would have resulted in a deadlock situation. 46 ENOLCK No locks available In fcntl(2) the setting or removing of record locks on a file cannot be accomplished because the system wide maximum number of record entries {FLOCK_MAX} has been exceeded. It can also occur when attempting to lock a file located on an NFS mounted file system and the appropriate NFS lock daemons are not running. 47 ECKPT Checkpoint/Restart error A process Checkpoint/Restart (CPR) operation has failed due to several possible fatal reasons. It can occur when an unrecoverable critical resource is associated with the target process during a checkpoint or restart. See cpr(1) for more detailed descriptions on CPR and error conditions. 50-57 Reserved numbers 60 ENOSTR Not a stream device A putmsg(2) or getmsg(2) system call was attempted on a file descriptor that is not a STREAMS device. 61 ENODATA No data available 62 ETIME Timer expired The timer set for a STREAMS ioctl(2) call has expired. The cause of this error is device specific and could indicate either a hardware or software failure, or perhaps a timeout value that is too short for the specific operation. The status of the ioctl(2) operation is indeterminate. 63 ENOSR Out of stream resources During a STREAMS open(2), either no STREAMS queues or no STREAMS head data structures were available. This is a temporary condition; one may recover from it if other processes release resources. 64 Reserved 65 ENOPKG Package not installed This error occurs when users attempt to use a system call from a package which has not been installed. 66-70 Reserved numbers 71 EPROTO Protocol error Some protocol error occurred. This error is device specific, but is generally not related to a hardware failure. 74-76 Reserved numbers 77 EBADMSG Bad message During a read(2), getmsg(2), or ioctl(2) I_RECVFD system call to a STREAMS device, something has come to the head of the queue that can't be processed. That something depends on the system call: read(2) - control information or a passed file descriptor. getmsg(2) - passed file descriptor. ioctl(2) - control or data information. 78 ENAMETOOLONG File name too long The size of a pathname string exceeds {PATH_MAX} , or a pathname component was longer than {NAME_MAX} and {_POSIX_NO_TRUNC} was in effect for that file. 79 EOVERFLOW Value too large for defined data type This error can occur for a variety of reasons, most to do with existing applications being compiled with data structures that cannot handle newer expanded sizes. It also occurs often if a 32 bit program attempts to access particular data about a 64 bit program. The user ID or group ID of an IPC or file system object was too large to be stored into appropriate member of the caller-provided structure. The size of a file system object is larger than can be represented in an off_t. This occurs when standard 32 bit programs attempt to access files greater than 2GB, or files greater than 2GB are accessed across a remote file system that cannot handle that size. 80-82 Reserved numbers 83 ELIBACC Can not access a needed shared library Trying to exec(2) an a.out that requires a shared library (to be linked in) and the shared library doesn't exist or the user doesn't have permission to use it. (obsolete) 84 ELIBBAD Accessing a corrupted shared library Trying to exec(2) an a.out that requires a shared library (to be linked in) and exec(2) could not load the shared library. The shared library is probably corrupted. (obsolete) 85 ELIBSCN .lib section in a.out corrupted Trying to exec(2) an a.out that requires a shared library (to be linked in) and there was erroneous data in the .lib section of the a.out. The .lib section tells exec(2) what shared libraries are needed. The a.out is probably corrupted. (obsolete) 86 ELIBMAX Attempting to link in more shared libraries than system limit Trying to exec(2) an a.out that requires more shared libraries (to be linked in) than the system imposed maximum {SHLIB_MAX}. (obsolete) 87 ELIBEXEC Cannot exec a shared library directly Trying to exec(2) a shared library directly. This is not allowed. (obsolete) 88 Reserved number 89 ENOSYS Function not implemented An attempt was made to use a function that is not available in this implementation. 90 ELOOP Too many symbolic links in path name traversal A path name lookup involved more than {SYMLINK_MAX}symboliclinks. 91 ERESTART Restartable system call Interrupted system call should be restarted. 92 ESTRPIPE If pipe/FIFO, don't sleep in stream head Streams pipe error (not externally visible). 93 ENOTEMPTY Directory not empty A directory with entries other than dot and dot-dot was supplied when an empty directory was expected. 94 Reserved number 95 ENOTSOCK Socket operation on non-socket 96 EDESTADDRREQ Destination address required A required address was omitted from an operation on a socket. 97 EMSGSIZE Inappropriate message buffer length A message sent on a socket was larger than the internal message buffer or some other network limit. 98 EPROTOTYPE Protocol wrong type for socket A protocol was specified which does not support the semantics of the socket type requested. For example, you cannot use the ARPA Internet UDP protocol with type SOCK_STREAM. 99 ENOPROTOOPT Option not supported by protocol A bad option was specified in a getsockopt(2) or setsockopt(2) call. 120 EPROTONOSUPPORT Protocol not supported The protocol has not been configured into the system or no implementation for it exists. 121 ESOCKTNOSUPPORT Socket type not supported The support for the socket type has not been configured into the system or no implementation exists. 122 EOPNOTSUPP Operation not supported on socket For example, trying to accept a connection on a datagram socket. 123 EPFNOSUPPORT Protocol family not supported The protocol family has not been configured into the system or no implementation exists. 124 EAFNOSUPPORT Address family not supported by protocol family An address incompatible with the requested protocol was used. For example, you shouldn't necessarily expect to be able to use PUP Internet addresses with ARPA Internet protocols. 125 EADDRINUSE Address already in use Only one usage of each address is normally permitted. 126 EADDRNOTAVAIL Can't assign requested address Normally results from an attempt to create a socket with an address not on this machine. 127 ENETDOWN Network is down A socket operation encountered a dead network. 128 ENETUNREACH Network is unreachable A socket operation was attempted to an unreachable network. 129 ENETRESET Network dropped connection on reset The host you were connected to crashed and rebooted. 130 ECONNABORTED Software caused connection abort A connection abort was caused internal to your host machine. 131 ECONNRESET Connection reset by peer A connection was forcibly closed by a peer. This normally results from a peer executing a shutdown(2) call. 132 ENOBUFS No buffer space available An operation on a socket or pipe performed because the system lacked sufficient buffer space. 133 EISCONN Socket is already connected A connect request was made on an already connected socket; or a sendto or sendmsg request on a connected socket specified a destination other than the connected party. 134 ENOTCONN Socket is not connected A request to send or receive data was disallowed because the socket was not connected. 135-142 Reserved numbers 143 ESHUTDOWN Can't send after socket shutdown A request to send data was disallowed because the socket had already been shut down with a previous shutdown(2) call. 144 ETOOMANYREFS Too many references: can't splice 145 ETIMEDOUT Connection timed out A connect request failed because the connected party did not properly respond after a period of time. (The timeout period is dependent on the communication protocol.) [see section on interruptibility.] 146 ECONNREFUSED Connection refused No connection could be made because the target machine actively refused it. 147 EHOSTDOWN Host is down 148 EHOSTUNREACH No route to host 149 EALREADY Operation already in progress An operation was attempted on a non-blocking object which already had an operation in progress. 150 EINPROGRESS Operation now in progress An operation which takes a long time to complete (such as a connect(2)) was attempted on a non-blocking object [see ioctl(2)]. 151 ESTALE Stale NFS file handle A file operation was attempted on an object in an NFS-mounted file system where the server has rejected the file handle sent by the client, e.g. because the file system has been unmounted on the server. If this error keeps recurring, the filesystem may need to be unmounted and remounted on the client. 158 ECANCELLED Cancelled The associated asynchronous operation was canceled before completion. 1008 ENOTSUP Not supported IRIX does not support this feature of a standard. 1009 ENOATTR Attribute not found Named attribute does not exist for this file. 1010 EFSCORRUPTED Filesystem is corrupted Operation failed because the filesystem is corrupted. 1011 EWRONGFS Mount with wrong filesystem type Mount failed because the wrong filesystem type was supplied, or because there is no filesystem on the device. 1133 EDQUOT Disc quota exceeded 1135 ENFSREMOTE Too many levels of remote in path DEFINITIONS Background Process Group Any process group that is not the foreground process group of a session that has established a connection with a controlling terminal. Controlling Process A session leader that established a connection to a controlling terminal. Controlling Terminal A terminal that is associated with a session. Each session may have, at most one controlling terminal associated with it and a controlling terminal may be associated with only one session. Certain input sequences from the controlling terminal cause signals to be sent to process groups in the session associated with the controlling terminal; see termio(7). Directory Directories organize files into a hierarchical system where directories are the nodes in the hierarchy. A directory is a file that catalogues the list of files, including directories (sub-directories), that are directly beneath it in the hierarchy. Entries in a directory file are called links. A link associates a file identifier with a filename. By convention, a directory contains at least two links, . (dot) and .. (dot-dot). The link called dot refers to the directory itself while dot-dot refers to its parent directory. The root directory, which is the top-most node of the hierarchy, has itself as its parent directory. The pathname of the root directory is / and the parent directory of the root directory is /. Downstream In a stream, the direction from stream head to driver. Driver In a stream, the driver provides the interface between peripheral hardware and the stream. A driver can also be a pseudo-driver, such as a multiplexor or log driver [see log(7)], which is not associated with a hardware device. Effective User ID and Effective Group ID An active process has an effective user ID and an effective group ID that are used to determine file access permissions (see below). The effective user ID and effective group ID are equal to the process's real user ID and real group ID respectively, unless the process or one of its ancestors evolved from a file that had the set-user-ID bit or set-group ID bit set [see exec(2)]. File Descriptor A file descriptor is a small integer used to do I/O on a file. The value of a file descriptor is from 0 to (NOFILES - 1). A process may have no more than NOFILES file descriptors open simultaneously. A file descriptor is returned by system calls such as open(2), or pipe(2). The file descriptor is used as an argument by calls such as read(2), write(2), ioctl(2), mmap(2), munmap(2), and close(2). NOFILES is a synonym for {OPEN_MAX}. File Access Permissions Read, write, and execute/search permissions on a file are granted to a process if one or more of the following are true: The effective user ID of the process is super-user. The effective user ID of the process matches the user ID of the owner of the file and the appropriate access bit of the ``owner'' portion (0700) of the file mode is set. The effective user ID of the process does not match the user ID of the owner of the file, and the effective group ID of the process matches the group of the file and the appropriate access bit of the ``group'' portion (0070) of the file mode is set. The effective user ID of the process does not match the user ID of the owner of the file, and the effective group ID of the process does not match the group ID of the file, and the appropriate access bit of the ``other'' portion (0007) of the file mode is set. Otherwise, the corresponding permissions are denied. File Name Names consisting of 1 to {NAME_MAX} characters may be used to name an ordinary file, special file or directory. These characters may be selected from the set of all character values excluding \0 (null) and the ASCII code for / (slash). Note that it is generally unwise to use *, ?, [, or ] as part of file names because of the special meaning attached to these characters by the shell [see sh(1)]. Although permitted, the use of unprintable characters in file names should be avoided. A file name is sometimes referred to as a pathname component. The interpretation of a pathname component is dependent on the values of NAME_MAX and _POSIX_NO_TRUNC associated with the path prefix of that component. If any pathname component is longer than NAME_MAX and _POSIX_NO_TRUNC is in effect for the path prefix of that component [see fpathconf(2) and limits(4)], it shall be considered an error condition in that implementation. Otherwise, the implementation shall use the first NAME_MAX bytes of the pathname component. Foreground Process Group Each session that has established a connection with a controlling terminal will distinguish one process group of the session as the foreground process group of the controlling terminal. This group has certain privileges when accessing its controlling terminal that are denied to background process groups. Message In a stream, one or more blocks of data or information, with associated STREAMS control structures. Messages can be of several defined types, which identify the message contents. Messages are the only means of transferring data and communicating within a stream. Message Queue In a stream, a linked list of messages awaiting processing by a module or driver. Message Queue Identifier A message queue identifier (msqid) is a unique positive integer created by a msgget(2) system call. Each msqid has a message queue and a data structure associated with it. The data structure is referred to as msqid_ds and contains the following members: struct ipc_perm msg_perm; struct msg *msg_first; struct msg *msg_last; ulong_t msg_cbytes; ulong_t msg_qnum; ulong_t msg_qbytes; pid_t msg_lspid; pid_t msg_lrpid; time_t msg_stime; time_t msg_rtime; time_t msg_ctime; msg_perm is an ipc_perm structure that specifies the message operation permission (see below). This structure includes the following members: uid_t cuid; /* creator user id */ gid_t cgid; /* creator group id */ uid_t uid; /* user id */ gid_t gid; /* group id */ mode_t mode; /* r/w permission */ ulong_t seq; /* slot usage sequence # */ key_t key; /* key */ msg *msg_first is a pointer to the first message on the queue. msg *msg_last is a pointer to the last message on the queue. msg_cbytes is the current number of bytes on the queue. msg_qnum is the number of messages currently on the queue. msg_qbytes is the maximum number of bytes allowed on the queue. msg_lspid is the process id of the last process that performed a msgsnd operation. msg_lrpid is the process id of the last process that performed a msgrcv operation. msg_stime is the time of the last msgsnd operation. msg_rtime is the time of the last msgrcv operation msg_ctime is the time of the last msgctl(2) operation that changed a member of the above structure. Message Operation Permissions In the msgop(2) and msgctl(2) system call descriptions, the permission required for an operation is given as "{token}", where "token" is the type of permission needed, interpreted as follows: 00400 Read by user 00200 Write by user 00040 Read by group 00020 Write by group 00004 Read by others 00002 Write by others Read and write permissions on a msqid are granted to a process if one or more of the following are true: The effective user ID of the process is super-user. The effective user ID of the process matches msg_perm.cuid or msg_perm.uid in the data structure associated with msqid and the appropriate bit of the ``user'' portion (0600) of msg_perm.mode is set. The effective group ID of the process matches msg_perm.cgid or msg_perm.gid and the appropriate bit of the ``group'' portion (060) of msg_perm.mode is set. The appropriate bit of the ``other'' portion (006) of msg_perm.mode is set. Otherwise, the corresponding permissions are denied. Module A module is an entity containing processing routines for input and output data. It always exists in the middle of a stream, between the stream's head and a driver. A module is the STREAMS counterpart to the commands in a Shell pipeline except that a module contains a pair of functions which allow independent bidirectional (downstream and upstream) data flow and processing. Multiplexor A multiplexor is a driver that allows streams associated with several user processes to be connected to a single driver, or several drivers to be connected to a single user process. STREAMS does not provide a general multiplexing driver, but does provide the facilities for constructing them, and for connecting multiplexed configurations of streams. Orphaned Process Group A process group in which the parent of every member in the group is either itself a member of the group, or is not a member of the process group's session. In other words, there is no process that can handle job control signals for the process group. Path Name and Path Prefix A path name is a null-terminated character string starting with an optional slash (/), followed by zero or more directory names separated by slashes, optionally followed by a file name. The entire length of a path name is limited to {PATH_MAX} characters. If a path name begins with a slash, the path search begins at the root directory. Otherwise, the search begins from the current working directory. A slash by itself names the root directory. Unless specifically stated otherwise, the null path name is treated as if it named a non-existent file. Process ID Each active process in the system is uniquely identified by a positive value called a process ID. This value is of the type pid_t. Parent Process ID A new process is created by a currently active process [see fork(2) and sproc(2)]. The parent process ID of a process is the process ID of its creator. Process Group Each process in the system is a member of a process group that is identified by a process group ID. Any process that is not a process group leader may create a new process group and become its leader. Any process that is not a process group leader may join an existing process group that shares the same session as the process. Note that all members of a given process group are also members of the same session, by definition. A newly created process joins the process group of its parent. A terminal may have a particular process group associated with it, which allows that group access to the terminal. This process group can be set only to process groups that are members of the terminal's session. The process group currently associated with the terminal is referred to as the foreground process group; all others are background process groups. A command interpreter, such as csh(1), that supports "job control" can allocate the terminal to different jobs, or process groups, by placing related processes in a single process group and associating this process group with the terminal. A terminal's associated process group may be set or examined by a process with sufficient privileges. Process Group Leader A process group leader is a process whose process ID is the same as its process group ID. Process Group ID Each active process is a member of a process group that is identified by a positive value called the process group ID. This ID is the process ID of the group leader. This grouping permits the signaling of related processes [see kill(2)]. Process Lifetime A process lifetime begins when the process is forked and ends after it exits, when its termination has been acknowledged by its parent process. See wait(2). Process Group Lifetime A process group lifetime begins when the process group is created by its process group leader, and ends when the lifetime of the last process in the group ends or when the last process in the group leaves the group by calling setpgid(2) or setsid(2). Read Queue In a stream, the message queue in a module or driver containing messages moving upstream. Real User ID and Real Group ID Each user allowed on the system is identified by a positive integer 0 to {UID_MAX} (2,147,483,647) called a real user ID. Each user is also a member of a group. The group is identified by a positive integer called the real group ID. An active process has a real user ID and real group ID that are set to the real user ID and real group ID, respectively, of the user responsible for the creation of the process. Root Directory and Current Working Directory Each process has associated with it a concept of a root directory and a current working directory for the purpose of resolving path name searches. The root directory of a process need not be the root directory of the root file system. Saved User ID and Saved Group ID The saved user ID and saved group ID are the values of the effective user ID and effective group ID prior to an exec of a file [see exec(2)]. Semaphore Identifier A semaphore identifier (semid) is a unique positive integer created by a semget(2) system call. Each semid has a set of semaphores and a data structure associated with it. The data structure is referred to as semid_ds and contains the following members: struct ipc_perm sem_perm; /* operation permission struct */ struct sem *sem_base; /* ptr to first semaphore in set */ ushort_t sem_nsems; /* number of sems in set */ time_t sem_otime; /* last operation time */ time_t sem_ctime; /* last change time */ /* Times measured in secs since */ /* 00:00:00 GMT, Jan. 1, 1970 */ sem_perm is an ipc_perm structure that specifies the semaphore operation permission (see below). This structure includes the following members: uid_t uid; /* user id */ gid_t gid; /* group id */ uid_t cuid; /* creator user id */ gid_t cgid; /* creator group id */ mode_t mode; /* r/a permission */ ulong_t seq; /* slot usage sequence number */ key_t key; /* key */ sem_nsems is equal to the number of semaphores in the set. Each semaphore in the set is referenced by a nonnegative integer referred to as a sem_num. Sem_num values run sequentially from 0 to the value of sem_nsems minus 1. sem_otime is the time of the last semop(2) operation. sem_ctime is the time of the last semctl(2) operation that changed a member of the above structure. A semaphore is a data structure called sem that contains the following members: ushort_t semval; /* semaphore value */ pid_t sempid; /* pid of last operation */ ushort_t semncnt; /* # awaiting semval > cval */ ushort_t semzcnt; /* # awaiting semval = 0 */ semval is a non-negative integer which is the actual value of the semaphore. sempid is equal to the process ID of the last process that performed a semaphore operation on this semaphore. semncnt is a count of the number of processes that are currently suspended awaiting this semaphore's semval to become greater than its current value. semzcnt is a count of the number of processes that are currently suspended awaiting this semaphore's semval to become zero. Semaphore Operation Permissions In the semop(2) and semctl(2) system call descriptions, the permission required for an operation is given as "{token}", where "token" is the type of permission needed interpreted as follows: 00400 Read by user 00200 Alter by user 00040 Read by group 00020 Alter by group 00004 Read by others 00002 Alter by others Read and alter permissions on a semid are granted to a process if one or more of the following are true: The effective user ID of the process is super-user. The effective user ID of the process matches sem_perm.cuid or sem_perm.uid in the data structure associated with semid and the appropriate bit of the ``user'' portion (0600) of sem_perm.mode is set. The effective group ID of the process matches sem_perm.cgid or sem_perm.gid and the appropriate bit of the ``group'' portion (060) of sem_perm.mode is set. The appropriate bit of the ``other'' portion (006) of sem_perm.mode is set. Otherwise, the corresponding permissions are denied. Sessions A session is a group of processes identified by a common ID called a session ID, capable of establishing a connection with a controlling terminal. Each session is associated with one "login" session (windows count as logins). Any process that is not a process group leader may create a new session and process group by calling setsid(2), which will put the process in a new session as its only member and as the session leader of that session. A newly created process joins the session of its creator. Session Leader A session leader is a process whose session ID is the same as its process and process group ID. Session Lifetime A session lifetime begins when the session is created by its session leader, and ends when the lifetime of the last process that is a member of the session ends, or when the last process that is a member of the session leaves the session by calling setsid(2). Shared Memory Identifier A shared memory identifier (shmid) is a unique positive integer created by a shmget(2) system call. Each shmid has a segment of memory (referred to as a shared memory segment) and a data structure associated with it. (Note that these shared memory segments must be explicitly removed by the user after the last reference to them is removed.) The data structure is referred to as shmid_ds and contains the following members: struct ipc_perm shm_perm; /* operation permission struct */ size_t shm_segsz; /* size of segment */ pid_t shm_lpid; /* pid of last operation */ pid_t shm_cpid; /* creator pid */ shmatt_t shm_nattch; /* number of current attaches */ ulong_t shm_cnattch; /* used only for shminfo */ time_t shm_atime; /* last attach time */ time_t shm_dtime; /* last detach time */ time_t shm_ctime; /* last change time */ /* Times measured in secs since */ /* 00:00:00 GMT, Jan. 1, 1970 */ shm_perm is an ipc_perm structure that specifies the shared memory operation permission (see below). This structure includes the following members: uid_t cuid; /* creator user id */ gid_t cgid; /* creator group id */ uid_t uid; /* user id */ gid_t gid; /* group id */ mode_t mode; /* r/w permission */ ulong_t seq; /* slot usage sequence # */ key_t key; /* key */ shm_segsz specifies the size of the shared memory segment in bytes. shm_cpid is the process id of the process that created the shared memory identifier. shm_lpid is the process id of the last process that performed a shmop(2) operation. shm_nattch is the number of processes that currently have this segment attached. shm_atime is the time of the last shmat(2) operation, shm_dtime is the time of the last shmdt(2) operation. shm_ctime is the time of the last shmctl(2) operation that changed one of the members of the above structure. Shared Memory Operation Permissions In the shmop(2) and shmctl(2) system call descriptions, the permission required for an operation is given as "{token}", where "token" is the type of permission needed interpreted as follows: 00400 Read by user 00200 Write by user 00040 Read by group 00020 Write by group 00004 Read by others 00002 Write by others Read and write permissions on a shmid are granted to a process if one or more of the following are true: The effective user ID of the process is super-user. The effective user ID of the process matches shm_perm.cuid or shm_perm.uid in the data structure associated with shmid and the appropriate bit of the ``user'' portion (0600) of shm_perm.mode is set. The effective group ID of the process matches shm_perm.cgid or shm_perm.gid and the appropriate bit of the ``group'' portion (060) of shm_perm.mode is set. The appropriate bit of the ``other'' portion (06) of shm_perm.mode is set. Otherwise, the corresponding permissions are denied. Special Processes The processes with a process ID of 0 and a process ID of 1 are special processes and are referred to as proc0 and proc1. Proc0 is the scheduler. Proc1 is the initialization process (init). Proc1 is the ancestor of every other process in the system and is used to control the process structure. STREAMS A set of kernel mechanisms that support the development of network services and data communication drivers. It defines interface standards for character input/output within the kernel and between the kernel and user level processes. The STREAMS mechanism is composed of utility routines, kernel facilities and a set of data structures. Stream A stream is a full-duplex data path within the kernel between a user process and driver routines. The primary components are a stream head, a driver and zero or more modules between the stream head and driver. A stream is analogous to a Shell pipeline except that data flow and processing are bidirectional. Stream Head In a stream, the stream head is the end of the stream that provides the interface between the stream and a user process. The principle functions of the stream head are processing STREAMS-related system calls, and passing data and information between a user process and the stream. Supplementary Group ID A process has up to {NGROUPS_MAX} supplementary group IDs used in determining file access permissions, in addition to the effective group ID. The supplementary group IDs of a process are set to the supplementary group IDs of the parent process when the process is created. Super-user A process is recognized as a super-user process and is granted special privileges, such as immunity from file permissions, if its effective user ID is 0. Upstream In a stream, the direction from driver to stream head. Write Queue In a stream, the message queue in a module or driver containing messages moving downstream. LIMITS The various limits can be categorized as follows: not modifiable, modifiable at sysgen time and modifiable at runtime. Most limits are controlled by variables that can be changed by editing the file /var/sysgen/stune or using the systune(1M) command. All the tunable parameters and their ranges are located in the directory /var/sysgen/mtune. Files in this directory should not be modified. Limits may apply system wide or per process. Most per process limits are inherited on fork, sproc, and exec. Some per process limits are managed via the setrlimit(2) resource management call. These resource limits have two values associated with them - a current and a maximum. A non- privileged process may change its current value as long as its less than the maximum. It may also lower its maximum, but once it does so, it may not raise it again. A privileged process may raise or lower both its current and maximum values. Resource limits may be queried programmatically via getrlimit(2) and via the shell limit or ulimit built-in command. They may also be set either programmatically or via the shell. The initial values (those given to process 1, and via inheritance to all other processes) may be set at sysgen time. {NPROC} is the maximum number of processes allowed to run concurrently on the system. It is modifiable at sysgen time by setting the variable nproc within the range defined in /var/sysgen/mtune/kernel. The current number in use and the current configured number may be retrieved via the sar -v command. {NFILE_MAX} is the maximum number of open files that can be simultaneously active system wide. This is limited only by the amount of memory in the system. The current number in use and the maximum number that has ever been allocated may be retrieved via the sar -v command. {FLOCK_MAX} is the maximum number of file locks system wide that may be active. This is limited only by the amount of memory in the system. The current number in use and the maximum number that has ever been allocated may be retrieved via the sar -v command. {NAME_MAX} is the maximum length of a file name. It is defined in limits.h and is not modifiable. {PATH_MAX} is the maximum length of a path name. It is defined in limits.h and is not modifiable. {LINK_MAX} is the maximum number of hard links that may be made to a given file. It is defined in limits.h and is not modifiable. {OPEN_MAX} is the maximum number of open files a given process may have. The minimum value this can have is defined in limits.h. It is the resource limit RLIMIT_NOFILE defined in setrlimit (2). The initial current and maximum limits may be changed by setting the variables rlimit_nofile_cur and rlimit_nofile_max within the range defined in /var/sysgen/mtune/kernel. The current number of open files configured may be obtained programmatically via getrlimit(2), getdtablesize(2), sysconf(2), or ulimit(2); and may be obtained from the shell by either the limit or ulimit built-in command. {CHILD_MAX} is the maximum number of processes a given user may have running simultaneously. The minimum value this can have is defined in limits.h. It is modifiable at runtime by setting the variable maxup within the range defined in /var/sysgen/mtune/kernel. The current configured maximum may be obtained from sysconf(2). {SHLIB_MAX} is the maximum number of shared libraries a program can link with. It is modifiable at runtime by setting the variable shlbmax within the range defined in /var/sysgen/mtune/kernel. {ARG_MAX} is the maximum number of bytes that may be passed via exec. The minimum value this can have is defined in limits.h. It is modifiable at runtime by setting the variable ncargs within the range defined in /var/sysgen/mtune/kernel. The current configured maximum may be obtained from sysconf(2). {FILESIZE_MAX} is the maximum size in bytes that a single file can grow to. It is the resource limit RLIMIT_FSIZE defined in setrlimit (2). The initial current and maximum limits may be changed by setting the variables rlimit_fsize_cur and rlimit_fsize_max within the range defined in /var/sysgen/mtune/kernel. {PROCSIZE_MAX} is the maximum virtual size a process can grow to. A process is made up an arbitrary number of virtual spaces. There are limits on the total size of process as well as certain limits on individual spaces. The overall limit is defined by the resource limit RLIMIT_VMEM. The initial current and maximum limits may be changed by setting the variables rlimit_vmem_cur and rlimit_vmem_max within the range defined in /var/sysgen/mtune/kernel. The maximum stack size is defined by the resource limit RLIMIT_STACK. The initial current and maximum limits may be changed by setting the variables rlimit_stack_cur and rlimit_stack_max within the range defined in /var/sysgen/mtune/kernel. The maximum data size is defined by the resource limit RLIMIT_DATA. The initial current and maximum limits may be changed by setting the variables rlimit_data_cur and rlimit_data_max within the range defined in /var/sysgen/mtune/kernel. The maximum size of a shared memory segment is modifiable at sysgen time by setting the variable shmmax within the range defined in /var/sysgen/mtune/shm. {SHMSEG_MAX} is the maximum number of shared memory segments system wide. It is modifiable at sysgen time by setting the variable shmmni within the range defined in /var/sysgen/mtune/shm. {SHMAT_MAX} is the maximum number of shared memory segments a given process may attach to. It is modifiable at sysgen time by setting the variable sshmseg within the range defined in /var/sysgen/mtune/shm. {SYMLINK_MAX} is the maximum number of symbolic links a given path name traversal will follow before assuming there is a loop. It is modifiable at runtime by setting the variable maxsymlinks within the range defined in /var/sysgen/mtune/kernel. {PLOCK_MAX} is the maximum number of pages a non-privileged process is allowed to lock at any one time. It is modifiable at runtime by setting the variable maxlkmem within the range defined in /var/sysgen/mtune/kernel. {PROFIL_MAX} is the maximum number of prof structures that can be passed as an argument to the sprofil (2) system call. It is modifiable at sysgen time by setting the variable nprofile within the range defined in /var/sysgen/mtune/kernel. {IOV_MAX} is the maximum number of iovec structures that can be passed to readv or writev. Currently, its value is 16. INTERRUPTIBILITY Certain system calls can be interrupted by the process receiving a signal. These include but are not limited to fcntl(2), open(2), read(2), write(2), and ioctl(2). The conditions under which a given system call can be interrupted are listed on each manual page. In addition, any file system oriented system call can either time out ( ETIMEDOUT or be interrupted EINTR ) if the object of the system call is located on a remote system accessed via NFS. Whether these system calls can time out or be interrupted is based on how the underlying file system was mounted on the local machine [see fstab(4) and mount(1M)]. All system calls can be automatically restarted upon receipt of a signal. Whether a system call should be restarted is configurable on a per signal basis (see sigaction(2)). SEE ALSO sar(1), lboot(1M), mount(1M), getrlimit(2), pathconf(2), sysconf(2), ulimit(2), intro(3), perror(3), fstab(4). Page 24