1 .\" Copyright (c) 1980, 1983, 1986, 1991, 1993
2 .\" The Regents of the University of California.
3 .\" All rights reserved. The Berkeley software License Agreement
4 .\" specifies the terms and conditions for redistribution.
6 .\" @(#)intro.2 8.5 (Berkeley) 2/27/95
16 .Nd introduction to system calls and error numbers
20 This section provides an overview of the system calls,
21 their error returns, and other common definitions and concepts.
23 Nearly all of the system calls provide an error number in the external
27 When a system call detects an error,
28 it returns an integer value
29 indicating failure (usually \-1)
33 (This allows interpretation of the failure on receiving
34 a \-1 and to take action accordingly.)
35 Successful calls never set
37 once set, it remains until another error occurs.
38 It should only be examined after an error has been reported, because
39 otherwise a leftover value from some previous error may be found
42 Many library functions that are not system calls also set
44 on return, in the same fashion.
45 In these cases a nonzero value may be left in
47 even upon successful return if some internal action failed.
50 The manual page for each system call will list some of the common
51 errno codes that system call can return, but that should not be
52 considered an exhaustive list, i.e.
53 a properly written program should be able to gracefully recover from
54 any error that a system call might return.
55 Documenting all the error codes that a system call can return in
56 a more specification-like manner would take more resources than
57 this project has available.
59 Note also that a number of system calls overload the meanings of these
60 error numbers, and that in these cases the meanings must be
61 interpreted according to the type and circumstances of the call.
63 The following is a list of the errors and their
67 .It Er 0 OK Em "Error 0" .
68 Not used. (The symbol "OK" is only used inside the kernel source.)
69 .It 1 EPERM Em "Operation not permitted" .
70 An attempt was made to perform an operation limited to processes
71 with appropriate privileges or to the owner of a file or other
73 .It Er 2 ENOENT Em "No such file or directory" .
74 A component of a specified pathname did not exist, or the
75 pathname was an empty string.
76 .It Er 3 ESRCH Em "No such process" .
77 No process could be found corresponding to that specified by the given
79 It Er 4 EINTR Em "Interrupted function call" .
80 An asynchronous signal (such as
84 was caught by the process during the execution of an interruptible
86 If the signal handler performs a normal return, the
87 interrupted function call will seem to have returned the error condition.
88 .It Er 5 EIO Em "Input/output error" .
89 Some physical input or output error occurred.
90 This error will not be reported until a subsequent operation on the same file
91 descriptor and may be lost (over written) by any subsequent errors.
92 .It Er 6 ENXIO Em "Device not configured" .
93 Input or output on a special file referred to a device that did not
95 made a request beyond the limits of the device.
96 This error may also occur when, for example,
97 a tape drive is not online or no disk pack is
99 .It Er 7 E2BIG Em "Arg list too long" .
100 The number of bytes used for the argument and environment
101 list of the new process exceeded the current limit of
106 .It Er 8 ENOEXEC Em "Exec format error" .
107 A request was made to execute a file
108 that, although it has the appropriate permissions,
109 was not in the format required for an
111 .It Er 9 EBADF Em "Bad file descriptor" .
112 A file descriptor argument was out of range, referred to no open file,
117 request was made to a file that was
118 only open for writing (or reading).
119 .It Er 10 ECHILD Em "\&No child processes" .
124 function was executed by a process that had no existing or unwaited-for
126 .It Er 11 EAGAIN Em "Resource temporarily unavailable" .
127 This is a temporary condition and later calls to the
128 same routine may complete normally.
129 .It Er 12 ENOMEM Em "Cannot allocate memory" .
130 The new process image required more memory than was allowed by the hardware
131 or by system-imposed memory management constraints.
132 Soft limits may be increased to their corresponding hard limits.
133 .It Er 13 EACCES Em "Permission denied" .
134 An attempt was made to access a file in a way forbidden
135 by its file access permissions.
136 .It Er 14 EFAULT Em "Bad address" .
137 The system detected an invalid address in attempting to
138 use an argument of a call.
139 The reliable detection of this error cannot be guaranteed and when not detected
140 may result in the generation of a signal, indicating an address violation,
141 which is sent to the process.
142 .It Er 15 ENOTBLK Em "Block device required" .
143 A block device operation was attempted on a non-block device or file.
144 .It Er 16 EBUSY Em "Resource busy" .
145 An attempt to use a system resource which was in use at the time
146 in a manner which would have conflicted with the request.
147 .It Er 17 EEXIST Em "File exists" .
148 An existing file was mentioned in an inappropriate context,
149 for instance, as the new link name in a
152 .It Er 18 EXDEV Em "Improper link" .
153 A hard link to a file on another file system
155 .It Er 19 ENODEV Em "Operation not supported by device" .
156 An attempt was made to apply an inappropriate
157 function to a device,
159 trying to read a write-only device such as a printer.
160 .It Er 20 ENOTDIR Em "Not a directory" .
161 A component of the specified pathname existed, but it was
162 not a directory, when a directory was expected.
163 .It Er 21 EISDIR Em "Is a directory" .
164 An attempt was made to open a directory with write mode specified.
165 .It Er 22 EINVAL Em "Invalid argument" .
166 Some invalid argument was supplied.
167 (For example, specifying an undefined signal to a
172 .It Er 23 ENFILE Em "Too many open files in system" .
173 Maximum number of file descriptors allowable on the system
174 has been reached and a requests for an open cannot be satisfied
175 until at least one has been closed.
176 .It Er 24 EMFILE Em "Too many open files" .
177 \*[Lt]As released, the limit on the number of
178 open files per process is 64.\*[Gt]
183 resource will obtain the current limit.
184 .It Er 25 ENOTTY Em "Inappropriate ioctl for device" .
185 A control function (see
187 was attempted for a file or
188 special device for which the operation was inappropriate.
189 .en 26 ETXTBSY "Text file busy
190 Attempt to execute a program that is open for writing. Obsolete under MINIX 3.
191 .It Er 27 EFBIG Em "File too large" .
192 The size of a file exceeded the maximum.
193 (The system-wide maximum file size is
194 2147483648 (2GB) bytes.
195 Each file system may impose a lower limit for files contained within it).
196 .It Er 28 ENOSPC Em "Device out of space" .
199 to an ordinary file, the creation of a
200 directory or symbolic link, or the creation of a directory
201 entry failed because no more disk blocks were available
202 on the file system, or the allocation of an inode for a newly
203 created file failed because no more inodes were available
205 .It Er 29 ESPIPE Em "Illegal seek" .
208 function was issued on a socket, pipe or
210 .It Er 30 EROFS Em "Read-only file system" .
211 An attempt was made to modify a file or directory
213 on a file system that was read-only at the time.
214 .It Er 31 EMLINK Em "Too many links" .
215 The number of hard links to a single file has exceeded the maximum.
216 (The system-wide maximum number of hard links is 32767.
217 Each file system may impose a lower limit for files contained within it).
218 .It Er 32 EPIPE Em "Broken pipe" .
219 A write on a pipe, socket or
221 for which there is no process
223 .It Er 33 EDOM Em "Numerical argument out of domain" .
224 A numerical input argument was outside the defined domain of the mathematical
226 .It Er 34 ERANGE Em "Result too large or too small" .
227 The result of the function is too large or too small to be represented
228 in the available space.
229 .It Er 35 EDEADLK Em "Resource deadlock avoided" .
230 An attempt was made to lock a system resource that
231 would have resulted in a deadlock situation.
232 .It Er 36 ENAMETOOLONG Em "File name too long" .
233 A component of a path name exceeded
235 characters, or an entire
236 path name exceeded 255
239 .It Er 37 ENOLCK Em "No locks available" .
240 A system-imposed limit on the number of simultaneous file
242 .It Er 38 ENOSYS Em "Function not implemented" .
243 Attempted a system call that is not available on this
245 .It Er 39 ENOTEMPTY Em "Directory not empty" .
246 A directory with entries other than
250 was supplied to a remove directory or rename call.
251 .It Er 40 ELOOP Em "Too many levels of symbolic links" .
252 A path name lookup involved more than 16
255 .It Er 41 ERESTART Em "Service restarted" .
256 .It Er 43 ERESTART Em "Identifier removed" .
257 An IPC identifier was removed while the current process was waiting on it.
258 .It Er 44 EILSEQ Em "Illegal byte sequence" .
259 A wide character/multibyte character encoding error occurred.
260 .It Er 45 EFTYPE Em "Inappropriate file type or format" .
261 Attempted a file operation on a file of a type for which it was invalid.
262 .It Er 46 EOVERFLOW Em "Value too large to be stored in data type" .
263 A numerical result of the function was too large to be stored in the
264 caller-provided space.
265 .It Er 50 EPACKSIZE Em "Invalid packet size" .
266 .It Er 51 ENOBUFS Em "\&No buffer space available" .
267 An operation on a socket or pipe was not performed because
268 the system lacked sufficient buffer space or because a queue was full.
269 .It Er 53 EBADMODE Em "Bad mode in ioctl" .
270 .It Er 54 EWOULDBLOCK Em "Would block" .
271 .It Er 55 ENETUNREACH Em "Network is unreachable" .
272 A socket operation was attempted to an unreachable network.
273 .It Er 56 EHOSTUNREACH Em "No route to host" .
274 A socket operation was attempted to an unreachable host.
275 .It Er 57 EISCONN Em "Socket is already connected" .
278 request was made on an already connected socket; or,
283 request on a connected socket specified a destination
284 when already connected.
285 .It Er 58 EADDRINUSE Em "Address already in use" .
286 Only one usage of each address is normally permitted.
287 .It Er 59 ECONNREFUSED Em "Connection refused" .
288 No connection could be made because the target machine actively
290 This usually results from trying to connect
291 to a service that is inactive on the foreign host.
292 .It Er 60 ECONNRESET Em "Connection reset by peer" .
293 A connection was forcibly closed by a peer.
294 This normally results from a loss of the connection on the remote
295 socket due to a timeout or a reboot.
296 .It Er 61 ETIMEDOUT Em "Operation timed out" .
301 request failed because the connected party did not
302 properly respond after a period of time.
303 (The timeout period is dependent on the communication protocol).
304 .It Er 62 EURG Em "Urgent data present" .
305 .It Er 63 ENOURG Em "No urgent data present" .
306 .It Er 64 ENOTCONN Em "Socket is not connected" .
307 An request to send or receive data was disallowed because
308 the socket was not connected and (when sending on a datagram socket)
309 no address was supplied.
310 .It Er 65 ESHUTDOWN Em "Cannot send after socket shutdown" .
311 A request to send data was disallowed because the socket
312 had already been shut down with a previous
315 .It Er 66 ENOCONN Em "No such connection" .
316 .It Er 67 EAFNOSUPPORT Em "Address family not supported by protocol family" .
317 An address incompatible with the requested protocol was used.
318 For example, you shouldn't necessarily expect to be able to use
323 .It Er 68 EPROTONOSUPPORT Em "Protocol not supported" .
324 The protocol has not been configured into the
325 system or no implementation for it exists.
326 .It Er 69 EPROTOTYPE Em "Protocol wrong type for socket" .
327 A protocol was specified that does not support the semantics of the
328 socket type requested.
329 For example, you cannot use the
335 .It Er 70 EINPROGRESS Em "Operation now in progress" .
336 An operation that takes a long time to complete (such as
339 was attempted on a non-blocking object (see
341 .It Er 71 EADDRNOTAVAIL Em "Cannot assign requested address" .
342 Normally results from an attempt to create a socket with an
343 address not on this machine.
344 .It Er 72 EALREADY Em "Operation already in progress" .
345 An operation was attempted on a non-blocking object that already
346 had an operation in progress.
347 .It Er 73 EMSGSIZE Em "Message too long" .
348 A message sent on a socket was larger than the internal message buffer
349 or some other network limit.
350 .It Er 74 ENOTSOCK Em "Socket operation on non-socket" .
352 .It Er 75 ENOPROTOOPT Em "Protocol option not available" .
353 A bad option or level was specified in a
358 .It Er 76 EOPNOTSUPP Em "Operation not supported" (has alias ENOTSUP) .
359 The attempted operation is not supported for the type of object referenced.
360 Usually this occurs when a file descriptor refers to a file or socket
361 that cannot support this operation,
362 for example, trying to
364 a connection on a datagram socket.
365 .It Er 77 ENETDOWN Em "Network is down" .
366 A socket operation encountered a dead network.
367 .It Er 78 EPFNOSUPPORT Em "Protocol family not supported" .
368 A socket operation specified an unsupported protocol family.
369 .It Er 79 EDESTADDRREQ Em "Destination address required" .
370 A required address was omitted from an operation on a socket.
371 .It Er 80 EHOSTDOWN Em "Host is down" .
372 The destination host has been determined to be down or disconnected.
377 Each active process in the system is uniquely identified by a positive
378 integer called a process ID. The range of this ID is from 1 to 29999.
379 .It Parent process ID
380 A new process is created by a currently active process; (see
382 The parent process ID of a process is initially the process ID of its creator.
383 If the creating process exits,
384 the parent process ID of each child is set to the ID of
388 Each active process is a member of a process group that is identified by
389 a positive integer called the process group ID.
390 This is the process ID of the group leader.
391 This grouping permits the signaling of related processes (see
394 A session is a set of one or more process groups.
395 A session is created by a successful call to
397 which causes the caller to become the only member of the only process
398 group in the new session.
400 A process that has created a new session by a successful call to
402 is known as a session leader.
403 Only a session leader may acquire a terminal as its controlling terminal (see
405 .It Controlling process
406 A session leader with a controlling terminal is a controlling process.
407 .It Controlling terminal
408 A terminal that is associated with a session is known as the controlling
409 terminal for that session and its members.
410 .It "Real User ID and Real Group ID"
411 Each user on the system is identified by a positive integer
412 termed the real user ID.
414 Each user is also a member of one or more groups.
415 One of these groups is distinguished from others and
416 used in implementing accounting facilities.
417 The positive integer corresponding to this distinguished group is
418 termed the real group ID.
420 All processes have a real user ID and real group ID.
421 These are initialized from the equivalent attributes
422 of the process that created it.
423 .It "Effective User Id, Effective Group Id, and Group Access List"
424 Access to system resources is governed by two values:
425 the effective user ID and the group access list.
426 (In POSIX.1, the group access list is known as the set of supplementary
427 group IDs, and it is unspecified whether the effective group ID is
428 a member of the list.)
430 The effective user ID and effective group ID are initially the
431 process's real user ID and real group ID respectively. Either
432 may be modified through execution of a set-user-ID or set-group-ID
433 file (possibly by one its ancestors) (see
436 The group access list is an additional set of group ID's
437 used only in determining resource accessibility.
438 Access checks are performed as described below in
439 .Qq File Access Permissions .
441 A process is recognized as a
443 process and is granted special privileges if its effective user ID is 0.
445 An integer assigned by the system when a file is referenced
450 or when a socket is created by
455 which uniquely identifies an access path to that file or socket from
456 a given process or any of its children.
458 Names consisting of up to 60
460 characters may be used to name
461 an ordinary file, special file, or directory.
463 These characters may be selected from the set of all
466 excluding 0 (NUL) and the
471 (The parity bit, bit 7, must be 0).
473 Note that it is generally unwise to use
480 file names because of the special meaning attached to these characters
484 .Tn NUL Ns -terminated
485 character string starting with an
488 followed by zero or more directory names separated
489 by slashes, optionally followed by a file name.
490 The total length of a path name must be less than 255
494 If a path name begins with a slash, the path search begins at the
497 Otherwise, the search begins from the current working directory.
498 A slash by itself names the root directory.
499 An empty string is not a valid pathname.
501 A directory is a special type of file that contains entries
502 that are references to other files.
503 Directory entries are called links.
504 By convention, a directory contains at least two links,
513 Dot refers to the directory itself and dot-dot refers to its parent directory.
514 .It "Root Directory and Current Working Directory"
515 Each process has associated with it a concept of a root directory
516 and a current working directory for the purpose of resolving path
518 A process's root directory need not be the root
519 directory of the root file system.
520 .It File Access Permissions
521 Every file in the file system has a set of access permissions.
522 These permissions are used in determining whether a process
523 may perform a requested operation on the file (such as opening
525 Access permissions are established at the time a file is created.
526 They may be changed at some later time through the
530 File access is broken down according to whether a file may be: read,
531 written, or executed.
532 Directory files use the execute permission to control if the
533 directory may be searched.
535 File access permissions are interpreted by the system as
536 they apply to three different classes of users: the owner
537 of the file, those users in the file's group, anyone else.
538 Every file has an independent set of access permissions for
539 each of these classes.
540 When an access check is made, the system decides if permission should be
541 granted by checking the access information applicable to the caller.
543 Read, write, and execute/search permissions on
544 a file are granted to a process if:
546 The process's effective user ID is that of the super-user.
547 (Note: even the super-user cannot execute a non-executable file).
549 The process's effective user ID matches the user ID of the owner
550 of the file and the owner permissions allow the access.
552 The process's effective user ID does not match the user ID of the
553 owner of the file, and either the process's effective
554 group ID matches the group ID
555 of the file, or the group ID of the file is in
556 the process's group access list,
557 and the group permissions allow the access.
559 Neither the effective user ID nor effective group ID
560 and group access list of the process
561 match the corresponding user ID and group ID of the file,
562 but the permissions for ``other users'' allow access.
564 Otherwise, permission is denied.
565 .It Sockets and Address Families
566 A socket is an endpoint for communication between processes.
567 Each socket has queues for sending and receiving data.
569 Sockets are typed according to their communications properties.
570 These properties include whether messages sent and received
571 at a socket require the name of the partner, whether communication
572 is reliable, the format used in naming message recipients, etc.
574 Each instance of the system supports some
575 collection of socket types; consult
577 for more information about the types available and
580 Each instance of the system supports some number of sets of
581 communications protocols.
582 Each protocol set supports addresses of a certain format.
583 An Address Family is the set of addresses for a specific group of protocols.
584 Each socket has an address
585 chosen from the address family in which the socket was created.