uninitialized error value when carrier/CLOCAL was already on
[unix-history] / usr / src / lib / libc / sys / intro.2
CommitLineData
91409caa 1.\" Copyright (c) 1980,1983,1986 Regents of the University of California.
5822f3c2
KM
2.\" All rights reserved. The Berkeley software License Agreement
3.\" specifies the terms and conditions for redistribution.
4.\"
f9238312 5.\" @(#)intro.2 6.9 (Berkeley) %G%
5822f3c2 6.\"
8af6b0db 7.TH INTRO 2 ""
5822f3c2
KM
8.UC 4
9.de en
10.HP
11\\$1 \\$2 \\$3
12.br
13..
14.SH NAME
5e1f9d48 15intro \- introduction to system calls and error numbers
5822f3c2 16.SH SYNOPSIS
91409caa 17.B #include <sys/errno.h>
5822f3c2 18.SH DESCRIPTION
f9238312
MK
19This section provides an overview of the system calls,
20their error returns, and other common definitions and concepts.
21.\".LP
22.\".B "System call restart"
23.\".PP
24.\"<more later...>
25.SH DIAGNOSTICS
26Most of these calls have one or more error returns.
5e1f9d48
KM
27An error condition is indicated by an otherwise impossible return
28value. This is almost always \-1; the individual descriptions
29specify the details.
91409caa
MK
30Note that a number of system calls overload the meanings of these
31error numbers, and that the meanings must be interpreted according
32to the type and circumstances of the call.
5822f3c2 33.PP
5e1f9d48
KM
34As with normal arguments, all return codes and values from
35functions are of type integer unless otherwise noted.
36An error number is also made available in the external
37variable \fIerrno\fP, which is not cleared
38on successful calls.
39Thus \fIerrno\fP should be tested only after an error has occurred.
5822f3c2 40.PP
5e1f9d48
KM
41The following is a complete list of the errors and their
42names as given in
91409caa 43.RI < sys/errno.h >.
5822f3c2
KM
44.en 0 \h'\w'EIO'u' "Error 0
45Unused.
46.en 1 EPERM "Not owner
47Typically this error indicates
48an attempt to modify a file in some way forbidden
49except to its owner or super-user.
50It is also returned for attempts
51by ordinary users to do things
52allowed only to the super-user.
53.en 2 ENOENT "No such file or directory
54This error occurs when a file name is specified
55and the file should exist but doesn't, or when one
56of the directories in a path name does not exist.
57.en 3 ESRCH "No such process
91409caa
MK
58The process or process group whose number was given
59does not exist, or any such process is already dead.
5822f3c2 60.en 4 EINTR "Interrupted system call
750588ad
SS
61An asynchronous signal (such as interrupt or quit)
62that the user has elected to catch
5822f3c2
KM
63occurred during a system call.
64If execution is resumed
91409caa
MK
65after processing the signal
66and the system call is not restarted,
5822f3c2
KM
67it will appear as if the interrupted system call
68returned this error condition.
69.en 5 EIO "I/O error
70Some physical I/O error occurred during a
71.I read
72or
73.IR write .
74This error may in some cases occur
75on a call following the one to which it actually applies.
76.en 6 ENXIO "No such device or address
750588ad 77I/O on a special file refers to a subdevice that does not
5822f3c2
KM
78exist,
79or beyond the limits of the device.
5e1f9d48
KM
80It may also occur when, for example, an illegal tape drive
81unit number is selected
82or a disk pack is not loaded on a drive.
5822f3c2 83.en 7 E2BIG "Arg list too long
91409caa
MK
84An argument list longer than 20480 bytes (or the current limit, NCARGS in
85.IR <sys/param.h> )
5822f3c2 86is presented to
5e1f9d48 87.IR execve .
5822f3c2
KM
88.en 8 ENOEXEC "Exec format error
89A request is made to execute a file
750588ad 90that, although it has the appropriate permissions,
9b718484
KD
91does not start with a valid magic number, (see
92.IR a.out (5)).
5822f3c2
KM
93.en 9 EBADF "Bad file number
94Either a file descriptor refers to no
95open file,
96or a read (resp. write) request is made to
750588ad 97a file that is open only for writing (resp. reading).
5822f3c2
KM
98.en 10 ECHILD "No children
99.I Wait
100and the process has no
101living or unwaited-for children.
102.en 11 EAGAIN "No more processes
103In a
104.I fork,
105the system's process table is full
106or the user is not allowed to create any more
107processes.
339207b0 108.en 12 ENOMEM "Not enough memory
5822f3c2 109During an
5e1f9d48 110.I execve
5822f3c2
KM
111or
112.I break,
5e1f9d48 113a program asks for more core or swap space than the system is
91409caa
MK
114able to supply,
115or a process size limit would be exceeded.
9b718484 116A lack of swap space is normally a temporary condition; however,
5e1f9d48
KM
117a lack of core
118is not a temporary condition; the maximum size
119of the text, data, and stack segments is a system parameter.
91409caa 120Soft limits may be increased to their corresponding hard limits.
5822f3c2
KM
121.en 13 EACCES "Permission denied
122An attempt was made to access a file in a way forbidden
123by the protection system.
124.en 14 EFAULT "Bad address
125The system encountered a hardware fault in attempting to
126access the arguments of a system call.
127.en 15 ENOTBLK "Block device required
128A plain file was mentioned where a block device was required,
9b718484 129e.g., in
5822f3c2 130.IR mount .
b5984ffe 131.en 16 EBUSY "Device busy
5822f3c2
KM
132An attempt to mount a device that was already mounted or
133an attempt was made to dismount a device
134on which there is an active file
91409caa 135(open file, current directory, mounted-on file, or active text segment).
b5984ffe 136A request was made to an exclusive access device that was already in use.
5822f3c2
KM
137.en 17 EEXIST "File exists
138An existing file was mentioned in an inappropriate context,
9b718484 139e.g.,
5822f3c2
KM
140.IR link .
141.en 18 EXDEV "Cross-device link
5e1f9d48 142A hard link to a file on another device
5822f3c2
KM
143was attempted.
144.en 19 ENODEV "No such device
145An attempt was made to apply an inappropriate
91409caa 146system call to a device,
9b718484 147e.g., to read a write-only device,
91409caa 148or the device is not configured by the system.
5822f3c2
KM
149.en 20 ENOTDIR "Not a directory
150A non-directory was specified where a directory
151is required,
9b718484 152for example, in a path name or
5822f3c2
KM
153as an argument to
154.IR chdir .
155.en 21 EISDIR "Is a directory
156An attempt to write on a directory.
157.en 22 EINVAL "Invalid argument
158Some invalid argument:
159dismounting a non-mounted
160device,
161mentioning an unknown signal in
162.I signal,
91409caa 163or some other argument inappropriate for the call.
9b718484
KD
164Also set by math functions, (see
165.IR math (3)).
5822f3c2
KM
166.en 23 ENFILE "File table overflow
167The system's table of open files is full,
168and temporarily no more
169.I opens
170can be accepted.
171.en 24 EMFILE "Too many open files
339207b0
KM
172As released, the limit on the number of
173open files per process is 64.
91409caa
MK
174.IR Getdtablesize (2)
175will obtain the current limit.
339207b0
KM
176Customary configuration limit on most other UNIX systems
177is 20 per process.
178.en 25 ENOTTY "Inappropriate ioctl for device
5e1f9d48
KM
179The file mentioned in an
180.I ioctl
91409caa 181is not a terminal or one of the
8af6b0db 182devices to which this call applies.
5822f3c2
KM
183.en 26 ETXTBSY "Text file busy
184An attempt to execute a pure-procedure
750588ad 185program that is currently open for writing.
5822f3c2
KM
186Also an attempt to open for writing a pure-procedure
187program that is being executed.
188.en 27 EFBIG "File too large
189The size of a file exceeded the maximum (about
91409caa
MK
190.if t 2\u\s-231\s+2\d
191.if n 2.1E9
5822f3c2
KM
192bytes).
193.en 28 ENOSPC "No space left on device
fd690c8b 194A
5822f3c2 195.I write
fd690c8b
KM
196to an ordinary file, the creation of a
197directory or symbolic link, or the creation of a directory
198entry failed because no more disk blocks are available
199on the file system, or the allocation of an inode for a newly
200created file failed because no more inodes are available
201on the file system.
5822f3c2
KM
202.en 29 ESPIPE "Illegal seek
203An
204.I lseek
91409caa 205was issued to a socket or pipe.
5e1f9d48 206This error may also be issued for
5822f3c2
KM
207other non-seekable devices.
208.en 30 EROFS "Read-only file system
209An attempt to modify a file or directory
210was made
211on a device mounted read-only.
212.en 31 EMLINK "Too many links
5e1f9d48 213An attempt to make more than 32767 hard links to a file.
5822f3c2 214.en 32 EPIPE "Broken pipe
5e1f9d48 215A write on a pipe or socket for which there is no process
5822f3c2
KM
216to read the data.
217This condition normally generates a signal;
91409caa 218the error is returned if the signal is caught or ignored.
339207b0 219.en 33 EDOM "Argument too large
5822f3c2
KM
220The argument of a function in the math package (3M)
221is out of the domain of the function.
222.en 34 ERANGE "Result too large
223The value of a function in the math package (3M)
224is unrepresentable within machine precision.
5e1f9d48 225.en 35 EWOULDBLOCK "Operation would block"
750588ad 226An operation that would cause a process to block was attempted
9b718484 227on an object in non-blocking mode (see \fIfcntl\fP(2)).
5e1f9d48 228.en 36 EINPROGRESS "Operation now in progress"
750588ad 229An operation that takes a long time to complete (such as
91409caa
MK
230a \fIconnect\fP(2)) was attempted on a non-blocking object (see
231\fIfcntl\fP(2)).
5e1f9d48 232.en 37 EALREADY "Operation already in progress"
750588ad 233An operation was attempted on a non-blocking object that already
5e1f9d48
KM
234had an operation in progress.
235.en 38 ENOTSOCK "Socket operation on non-socket"
236Self-explanatory.
237.en 39 EDESTADDRREQ "Destination address required"
238A required address was omitted from an operation on a socket.
239.en 40 EMSGSIZE "Message too long"
91409caa
MK
240A message sent on a socket was larger than the internal message buffer
241or some other network limit.
5e1f9d48 242.en 41 EPROTOTYPE "Protocol wrong type for socket"
750588ad 243A protocol was specified that does not support the semantics of the
9b718484 244socket type requested. For example, you cannot use the ARPA Internet
5e1f9d48 245UDP protocol with type SOCK_STREAM.
339207b0 246.en 42 ENOPROTOOPT "Option not supported by protocol
91409caa 247A bad option or level was specified in a
5e1f9d48
KM
248.IR getsockopt (2)
249or
250.IR setsockopt (2)
251call.
252.en 43 EPROTONOSUPPORT "Protocol not supported"
253The protocol has not been configured into the
254system or no implementation for it exists.
255.en 44 ESOCKTNOSUPPORT "Socket type not supported"
256The support for the socket type has not been configured into the
257system or no implementation for it exists.
258.en 45 EOPNOTSUPP "Operation not supported on socket"
259For example, trying to \fIaccept\fP a connection on a datagram socket.
260.en 46 EPFNOSUPPORT "Protocol family not supported"
261The protocol family has not been configured into the
262system or no implementation for it exists.
263.en 47 EAFNOSUPPORT "Address family not supported by protocol family"
264An address incompatible with the requested protocol was used.
91409caa
MK
265For example, you shouldn't necessarily expect to be able to use NS
266addresses with ARPA Internet protocols.
5e1f9d48
KM
267.en 48 EADDRINUSE "Address already in use"
268Only one usage of each address is normally permitted.
269.en 49 EADDRNOTAVAIL "Can't assign requested address"
270Normally results from an attempt to create a socket with an
271address not on this machine.
272.en 50 ENETDOWN "Network is down"
273A socket operation encountered a dead network.
274.en 51 ENETUNREACH "Network is unreachable"
275A socket operation was attempted to an unreachable network.
276.en 52 ENETRESET "Network dropped connection on reset"
277The host you were connected to crashed and rebooted.
278.en 53 ECONNABORTED "Software caused connection abort"
279A connection abort was caused internal to your host machine.
280.en 54 ECONNRESET "Connection reset by peer"
281A connection was forcibly closed by a peer. This normally
91409caa
MK
282results from a loss of the connection on the remote socket
283due to a timeout or a reboot.
5e1f9d48
KM
284.en 55 ENOBUFS "No buffer space available"
285An operation on a socket or pipe was not performed because
91409caa 286the system lacked sufficient buffer space or because a queue was full.
5e1f9d48
KM
287.en 56 EISCONN "Socket is already connected"
288A
289.I connect
290request was made on an already connected socket; or,
291a
292.I sendto
293or
294.I sendmsg
295request on a connected socket specified a destination
91409caa 296when already connected.
5e1f9d48
KM
297.en 57 ENOTCONN "Socket is not connected"
298An request to send or receive data was disallowed because
91409caa
MK
299the socket is not connected and (when sending on a datagram socket)
300no address was supplied.
5e1f9d48
KM
301.en 58 ESHUTDOWN "Can't send after socket shutdown"
302A request to send data was disallowed because the socket
303had already been shut down with a previous
304.IR shutdown (2)
305call.
306.en 59 \fIunused\fP
307.en 60 ETIMEDOUT "Connection timed out"
308A
309.I connect
91409caa
MK
310or
311.I send
5e1f9d48
KM
312request failed because the connected party did not
313properly respond after a period of time. (The timeout
314period is dependent on the communication protocol.)
315.en 61 ECONNREFUSED "Connection refused"
316No connection could be made because the target machine actively
317refused it. This usually results from trying to connect
750588ad 318to a service that is inactive on the foreign host.
5e1f9d48
KM
319.en 62 ELOOP "Too many levels of symbolic links"
320A path name lookup involved more than 8 symbolic links.
321.en 63 ENAMETOOLONG "File name too long"
91409caa
MK
322A component of a path name exceeded 255 (MAXNAMELEN) characters, or an entire
323path name exceeded 1023 (MAXPATHLEN-1) characters.
8af6b0db
KM
324.en 64 EHOSTDOWN "Host is down"
325A socket operation failed because the destination host was down.
326.en 65 EHOSTUNREACH "Host is unreachable"
327A socket operation was attempted to an unreachable host.
328.en 66 ENOTEMPTY "Directory not empty"
5e1f9d48
KM
329A directory with entries other than \*(lq.\*(rq and \*(lq..\*(rq
330was supplied to a remove directory or rename call.
8af6b0db 331...en 67 EPROCLIM "Too many processes"
a0f47338
KB
332.en 68 EUSERS "Too many users"
333The quota system ran out of table entries.
8af6b0db 334.en 69 EDQUOT "Disc quota exceeded"
fd690c8b 335A
91409caa 336.I write
fd690c8b
KM
337to an ordinary file, the creation of a
338directory or symbolic link, or the creation of a directory
339entry failed because the user's quota of disk blocks was
340exhausted, or the allocation of an inode for a newly
341created file failed because the user's quota of inodes
342was exhausted.
5e1f9d48
KM
343.SH DEFINITIONS
344.TP 5
345Process ID
346.br
347Each active process in the system is uniquely identified by a positive
91409caa 348integer called a process ID. The range of this ID is from 0 to 30000.
5e1f9d48
KM
349.TP 5
350Parent process ID
351.br
9b718484
KD
352A new process is created by a currently active process; (see
353.IR fork (2)).
5e1f9d48
KM
354The parent process ID of a process is the process ID of its creator.
355.TP 5
356Process Group ID
357.br
358Each active process is a member of a process group that is identified by
359a positive integer called the process group ID. This is the process
91409caa 360ID of the group leader. This grouping permits the signaling of related
5e1f9d48
KM
361processes (see
362.IR killpg (2))
363and the job control mechanisms of
364.IR csh (1).
365.TP 5
366Tty Group ID
367.br
368Each active process can be a member of a terminal group that is identified
369by a positive integer called the tty group ID. This grouping is used
370to arbitrate between multiple jobs contending for the same terminal;
9b718484
KD
371(see
372.IR csh (1)
5822f3c2 373and
9b718484 374.IR tty (4)).
5e1f9d48
KM
375.TP 5
376Real User ID and Real Group ID
377.br
378Each user on the system is identified by a positive integer
379termed the real user ID.
5822f3c2 380.IP
5e1f9d48
KM
381Each user is also a member of one or more groups.
382One of these groups is distinguished from others and
383used in implementing accounting facilities. The positive
384integer corresponding to this distinguished group is termed
385the real group ID.
386.IP
387All processes have a real user ID and real group ID.
388These are initialized from the equivalent attributes
750588ad 389of the process that created it.
5e1f9d48
KM
390.TP 5
391Effective User Id, Effective Group Id, and Access Groups
392.br
393Access to system resources is governed by three values:
394the effective user ID, the effective group ID, and the
395group access list.
396.IP
397The effective user ID and effective group ID are initially the
398process's real user ID and real group ID respectively. Either
399may be modified through execution of a set-user-ID or set-group-ID
9b718484
KD
400file (possibly by one its ancestors) (see
401.IR execve (2)).
5e1f9d48
KM
402.IP
403The group access list is an additional set of group ID's
404used only in determining resource accessibility. Access checks
405are performed as described below in ``File Access Permissions''.
406.TP 5
407Super-user
408.br
409A process is recognized as a
410.I super-user
411process and is granted special privileges if its effective user ID is 0.
412.TP 5
413Special Processes
414.br
415The processes with a process ID's of 0, 1, and 2 are special.
416Process 0 is the scheduler. Process 1 is the initialization process
417.IR init ,
418and is the ancestor of every other process in the system.
419It is used to control the process structure.
420Process 2 is the paging daemon.
421.TP 5
422Descriptor
423.br
424An integer assigned by the system when a file is referenced
425by
91409caa
MK
426.IR open (2)
427or
5e1f9d48 428.IR dup (2),
91409caa
MK
429or when a socket is created by
430.IR pipe (2),
5e1f9d48
KM
431.IR socket (2)
432or
750588ad 433.IR socketpair (2),
5e1f9d48
KM
434which uniquely identifies an access path to that file or socket from
435a given process or any of its children.
436.TP 5
437File Name
438.br
91409caa 439Names consisting of up to 255 (MAXNAMELEN) characters may be used to name
5e1f9d48
KM
440an ordinary file, special file, or directory.
441.IP
442These characters may be selected from the set of all ASCII character
443excluding 0 (null) and the ASCII code for / (slash). (The parity bit,
444bit 8, must be 0.)
445.IP
446Note that it is generally unwise to use *, ?, [ or ] as part of
447file names because of the special meaning attached to these characters
448by the shell.
449.TP 5
450Path Name
451.br
452A path name is a null-terminated character string starting with an
453optional slash (/), followed by zero or more directory names separated
454by slashes, optionally followed by a file name.
91409caa 455The total length of a path name must be less than 1024 (MAXPATHLEN) characters.
5e1f9d48
KM
456.IP
457If a path name begins with a slash, the path search begins at the
458.I root
459directory.
460Otherwise, the search begins from the current working directory.
461A slash by itself names the root directory. A null
462pathname refers to the current directory.
463.TP 5
464Directory
465.br
750588ad
SS
466A directory is a special type of file that contains entries
467that are references to other files.
5e1f9d48
KM
468Directory entries are called links. By convention, a directory
469contains at least two links, . and .., referred to as
470.I dot
5822f3c2 471and
5e1f9d48
KM
472.I dot-dot
473respectively. Dot refers to the directory itself and
474dot-dot refers to its parent directory.
475.TP 5
476Root Directory and Current Working Directory
477.br
478Each process has associated with it a concept of a root directory
479and a current working directory for the purpose of resolving path
480name searches. A process's root directory need not be the root
481directory of the root file system.
482.TP 5
483File Access Permissions
484.br
485Every file in the file system has a set of access permissions.
486These permissions are used in determining whether a process
487may perform a requested operation on the file (such as opening
488a file for writing). Access permissions are established at the
489time a file is created. They may be changed at some later time
490through the
491.IR chmod (2)
492call.
493.IP
494File access is broken down according to whether a file may be: read,
495written, or executed. Directory files use the execute
496permission to control if the directory may be searched.
497.IP
498File access permissions are interpreted by the system as
499they apply to three different classes of users: the owner
500of the file, those users in the file's group, anyone else.
501Every file has an independent set of access permissions for
502each of these classes. When an access check is made, the system
503decides if permission should be granted by checking the access
504information applicable to the caller.
505.IP
506Read, write, and execute/search permissions on
507a file are granted to a process if:
508.IP
509The process's effective user ID is that of the super-user.
510.IP
511The process's effective user ID matches the user ID of the owner
512of the file and the owner permissions allow the access.
513.IP
514The process's effective user ID does not match the user ID of the
515owner of the file, and either the process's effective
516group ID matches the group ID
517of the file, or the group ID of the file is in
518the process's group access list,
519and the group permissions allow the access.
520.IP
521Neither the effective user ID nor effective group ID
522and group access list of the process
523match the corresponding user ID and group ID of the file,
524but the permissions for ``other users'' allow access.
525.IP
526Otherwise, permission is denied.
527.TP 5
528Sockets and Address Families
529.IP
530A socket is an endpoint for communication between processes.
531Each socket has queues for sending and receiving data.
532.IP
533Sockets are typed according to their communications properties.
534These properties include whether messages sent and received
535at a socket require the name of the partner, whether communication
536is reliable, the format used in naming message recipients, etc.
537.IP
538Each instance of the system supports some
539collection of socket types; consult
540.IR socket (2)
541for more information about the types available and
542their properties.
543.IP
544Each instance of the system supports some number of sets of
545communications protocols. Each protocol set supports addresses
546of a certain format. An Address Family is the set of addresses
547for a specific group of protocols. Each socket has an address
548chosen from the address family in which the socket was created.
549.SH SEE ALSO
550intro(3), perror(3)