1INTRO(2)                      System Calls Manual                     INTRO(2)
2
3
4

NAME

6       intro - introduction to system calls and error numbers
7

SYNOPSIS

9       #include <sys/errno.h>
10

DESCRIPTION

12       This  section  describes  all of the system calls.  Most of these calls
13       have one or more error returns.  An error condition is indicated by  an
14       otherwise impossible return value.  This is almost always -1; the indi‐
15       vidual descriptions specify the details.  Note that a number of  system
16       calls  overload the meanings of these error numbers, and that the mean‐
17       ings must be interpreted according to the type and circumstances of the
18       call.
19
20       As  with  normal  arguments, all return codes and values from functions
21       are of type integer unless otherwise noted.  An error  number  is  also
22       made  available in the external variable errno, which is not cleared on
23       successful calls.  Thus errno should be tested only after an error  has
24       occurred.
25
26       The following is a complete list of the errors and their names as given
27       in <sys/errno.h>.
28
29       0       Error 0
30              Unused.
31
32       1  EPERM  Not owner
33              Typically this error indicates an attempt to modify  a  file  in
34              some  way  forbidden  except  to its owner or super-user.  It is
35              also returned for  attempts  by  ordinary  users  to  do  things
36              allowed only to the super-user.
37
38       2  ENOENT  No such file or directory
39              This  error  occurs  when  a file name is specified and the file
40              should exist but doesn't, or when one of the  directories  in  a
41              path name does not exist.
42
43       3  ESRCH  No such process
44              The  process  or  process  group whose number was given does not
45              exist, or any such process is already dead.
46
47       4  EINTR  Interrupted system call
48              An asynchronous signal (such as interrupt or quit) that the user
49              has  elected  to catch occurred during a system call.  If execu‐
50              tion is resumed after processing the signal and the system  call
51              is  not  restarted,  it will appear as if the interrupted system
52              call returned this error condition.
53
54       5  EIO  I/O error
55              Some physical I/O error occurred during a read or  write.   This
56              error  may  in  some  cases occur on a call following the one to
57              which it actually applies.
58
59       6  ENXIO  No such device or address
60              I/O on a special file refers to a subdevice that does not exist,
61              or beyond the limits of the device.  It may also occur when, for
62              example, an illegal tape drive unit number is selected or a disk
63              pack is not loaded on a drive.
64
65       7  E2BIG  Arg list too long
66              An  argument list longer than 20480 bytes (or the current limit,
67              NCARGS in <sys/param.h>) is presented to execve.
68
69       8  ENOEXEC  Exec format error
70              A request is made to execute a file that, although  it  has  the
71              appropriate  permissions, does not start with a valid magic num‐
72              ber, (see a.out(5)).
73
74       9  EBADF  Bad file number
75              Either a file descriptor refers to  no  open  file,  or  a  read
76              (resp.  write)  request  is made to a file that is open only for
77              writing (resp. reading).
78
79       10  ECHILD  No children
80              Wait and the process has no living or unwaited-for children.
81
82       11  EAGAIN  No more processes
83              In a fork, the system's process table is full or the user is not
84              allowed to create any more processes.
85
86       12  ENOMEM  Not enough memory
87              During  an execve or break, a program asks for more core or swap
88              space than the system is able to supply, or a process size limit
89              would be exceeded.  A lack of swap space is normally a temporary
90              condition; however, a lack of core is not a temporary condition;
91              the maximum size of the text, data, and stack segments is a sys‐
92              tem parameter.  Soft limits may be  increased  to  their  corre‐
93              sponding hard limits.
94
95       13  EACCES  Permission denied
96              An  attempt  was made to access a file in a way forbidden by the
97              protection system.
98
99       14  EFAULT  Bad address
100              The system encountered a hardware fault in attempting to  access
101              the arguments of a system call.
102
103       15  ENOTBLK  Block device required
104              A  plain  file  was mentioned where a block device was required,
105              e.g., in mount.
106
107       16  EBUSY  Device busy
108              An attempt to mount a device that  was  already  mounted  or  an
109              attempt  was  made  to  dismount  a  device on which there is an
110              active file (open file, current directory, mounted-on  file,  or
111              active text segment).  A request was made to an exclusive access
112              device that was already in use.
113
114       17  EEXIST  File exists
115              An existing file was  mentioned  in  an  inappropriate  context,
116              e.g., link.
117
118       18  EXDEV  Cross-device link
119              A hard link to a file on another device was attempted.
120
121       19  ENODEV  No such device
122              An  attempt  was made to apply an inappropriate system call to a
123              device, e.g., to read a write-only device, or the device is  not
124              configured by the system.
125
126       20  ENOTDIR  Not a directory
127              A non-directory was specified where a directory is required, for
128              example, in a path name or as an argument to chdir.
129
130       21  EISDIR  Is a directory
131              An attempt to write on a directory.
132
133       22  EINVAL  Invalid argument
134              Some invalid argument: dismounting a  non-mounted  device,  men‐
135              tioning  an  unknown  signal  in  signal, or some other argument
136              inappropriate for the call.  Also set by  math  functions,  (see
137              math(3)).
138
139       23  ENFILE  File table overflow
140              The  system's  table  of  open files is full, and temporarily no
141              more opens can be accepted.
142
143       24  EMFILE  Too many open files
144              As released, the limit on the number of open files  per  process
145              is 64.  Getdtablesize(2) will obtain the current limit.  Custom‐
146              ary configuration limit on most other UNIX  systems  is  20  per
147              process.
148
149       25  ENOTTY  Inappropriate ioctl for device
150              The  file  mentioned in an ioctl is not a terminal or one of the
151              devices to which this call applies.
152
153       26  ETXTBSY  Text file busy
154              An attempt to execute a pure-procedure program that is currently
155              open  for  writing.  Also an attempt to open for writing a pure-
156              procedure program that is being executed.
157
158       27  EFBIG  File too large
159              The size of a file exceeded the maximum (about 2.1E9 bytes).
160
161       28  ENOSPC  No space left on device
162              A write to an ordinary file, the creation of a directory or sym‐
163              bolic  link, or the creation of a directory entry failed because
164              no more disk blocks are available on the  file  system,  or  the
165              allocation  of  an inode for a newly created file failed because
166              no more inodes are available on the file system.
167
168       29  ESPIPE  Illegal seek
169              An lseek was issued to a socket or pipe.  This error may also be
170              issued for other non-seekable devices.
171
172       30  EROFS  Read-only file system
173              An  attempt  to  modify a file or directory was made on a device
174              mounted read-only.
175
176       31  EMLINK  Too many links
177              An attempt to make more than 32767 hard links to a file.
178
179       32  EPIPE  Broken pipe
180              A write on a pipe or socket for which there  is  no  process  to
181              read  the data.  This condition normally generates a signal; the
182              error is returned if the signal is caught or ignored.
183
184       33  EDOM  Argument too large
185              The argument of a function in the math package (3M)  is  out  of
186              the domain of the function.
187
188       34  ERANGE  Result too large
189              The  value  of  a  function in the math package (3M) is unrepre‐
190              sentable within machine precision.
191
192       35  EWOULDBLOCK  Operation would block
193              An operation that would cause a process to block  was  attempted
194              on an object in non-blocking mode (see fcntl(2)).
195
196       36  EINPROGRESS  Operation now in progress
197              An  operation that takes a long time to complete (such as a con‐
198              nect(2)) was attempted on a non-blocking object (see fcntl(2)).
199
200       37  EALREADY  Operation already in progress
201              An operation was attempted on a non-blocking object that already
202              had an operation in progress.
203
204       38  ENOTSOCK  Socket operation on non-socket
205              Self-explanatory.
206
207       39  EDESTADDRREQ  Destination address required
208              A required address was omitted from an operation on a socket.
209
210       40  EMSGSIZE  Message too long
211              A  message sent on a socket was larger than the internal message
212              buffer or some other network limit.
213
214       41  EPROTOTYPE  Protocol wrong type for socket
215              A protocol was specified that does not support the semantics  of
216              the  socket type requested. For example, you cannot use the ARPA
217              Internet UDP protocol with type SOCK_STREAM.
218
219       42  ENOPROTOOPT  Option not supported by protocol
220              A bad option or level was specified in a getsockopt(2)  or  set‐
221              sockopt(2) call.
222
223       43  EPROTONOSUPPORT  Protocol not supported
224              The  protocol  has  not  been  configured  into the system or no
225              implementation for it exists.
226
227       44  ESOCKTNOSUPPORT  Socket type not supported
228              The support for the socket type has not been configured into the
229              system or no implementation for it exists.
230
231       45  EOPNOTSUPP  Operation not supported on socket
232              For example, trying to accept a connection on a datagram socket.
233
234       46  EPFNOSUPPORT  Protocol family not supported
235              The  protocol  family has not been configured into the system or
236              no implementation for it exists.
237
238       47  EAFNOSUPPORT  Address family not supported by protocol family
239              An address incompatible with the requested  protocol  was  used.
240              For  example, you shouldn't necessarily expect to be able to use
241              NS addresses with ARPA Internet protocols.
242
243       48  EADDRINUSE  Address already in use
244              Only one usage of each address is normally permitted.
245
246       49  EADDRNOTAVAIL  Can't assign requested address
247              Normally results from an attempt to  create  a  socket  with  an
248              address not on this machine.
249
250       50  ENETDOWN  Network is down
251              A socket operation encountered a dead network.
252
253       51  ENETUNREACH  Network is unreachable
254              A socket operation was attempted to an unreachable network.
255
256       52  ENETRESET  Network dropped connection on reset
257              The host you were connected to crashed and rebooted.
258
259       53  ECONNABORTED  Software caused connection abort
260              A connection abort was caused internal to your host machine.
261
262       54  ECONNRESET  Connection reset by peer
263              A  connection  was  forcibly  closed  by  a peer.  This normally
264              results from a loss of the connection on the remote  socket  due
265              to a timeout or a reboot.
266
267       55  ENOBUFS  No buffer space available
268              An  operation  on a socket or pipe was not performed because the
269              system lacked sufficient buffer space or  because  a  queue  was
270              full.
271
272       56  EISCONN  Socket is already connected
273              A connect request was made on an already connected socket; or, a
274              sendto or sendmsg request on a connected socket specified a des‐
275              tination when already connected.
276
277       57  ENOTCONN  Socket is not connected
278              An  request  to  send or receive data was disallowed because the
279              socket is not connected and (when sending on a  datagram socket)
280              no address was supplied.
281
282       58  ESHUTDOWN  Can't send after socket shutdown
283              A  request  to  send  data was disallowed because the socket had
284              already been shut down with a previous shutdown(2) call.
285
286       59  unused
287
288       60  ETIMEDOUT  Connection timed out
289              A connect or send request failed because the connected party did
290              not  properly  respond  after  a  period  of time.  (The timeout
291              period is dependent on the communication protocol.)
292
293       61  ECONNREFUSED  Connection refused
294              No connection could be made because the target machine  actively
295              refused  it.   This  usually results from trying to connect to a
296              service that is inactive on the foreign host.
297
298       62  ELOOP  Too many levels of symbolic links
299              A path name lookup involved more than 8 symbolic links.
300
301       63  ENAMETOOLONG  File name too long
302              A component of a path name exceeded 255 (MAXNAMELEN) characters,
303              or an entire path name exceeded 1023 (MAXPATHLEN-1) characters.
304
305       64  EHOSTDOWN  Host is down
306              A socket operation failed because the destination host was down.
307
308       65  EHOSTUNREACH  Host is unreachable
309              A socket operation was attempted to an unreachable host.
310
311       66  ENOTEMPTY  Directory not empty
312              A  directory  with entries other than “.” and “..”  was supplied
313              to a remove directory or rename call.
314
315       69  EDQUOT  Disc quota exceeded
316              A write to an ordinary file, the creation of a directory or sym‐
317              bolic  link, or the creation of a directory entry failed because
318              the user's quota of disk blocks was exhausted, or the allocation
319              of  an  inode for a newly created file failed because the user's
320              quota of inodes was exhausted.
321

DEFINITIONS

323       Process ID
324            Each active process in the system is uniquely identified by a pos‐
325            itive integer called a process ID.  The range of this ID is from 0
326            to 30000.
327
328       Parent process ID
329            A new process is created  by  a  currently  active  process;  (see
330            fork(2)).  The parent process ID of a process is the process ID of
331            its creator.
332
333       Process Group ID
334            Each active process is a member of a process group that is identi‐
335            fied  by  a positive integer called the process group ID.  This is
336            the process ID of the group leader.   This  grouping  permits  the
337            signaling of related processes (see killpg(2)) and the job control
338            mechanisms of csh(1).
339
340       Tty Group ID
341            Each active process can be a member of a terminal  group  that  is
342            identified  by  a  positive integer called the tty group ID.  This
343            grouping is used to arbitrate between multiple jobs contending for
344            the same terminal; (see csh(1) and tty(4)).
345
346       Real User ID and Real Group ID
347            Each user on the system is identified by a positive integer termed
348            the real user ID.
349
350            Each user is also a member of one or more groups.   One  of  these
351            groups  is  distinguished  from  others  and  used in implementing
352            accounting facilities.  The positive integer corresponding to this
353            distinguished group is termed the real group ID.
354
355            All  processes  have  a real user ID and real group ID.  These are
356            initialized from the equivalent attributes  of  the  process  that
357            created it.
358
359       Effective User Id, Effective Group Id, and Access Groups
360            Access to system resources is governed by three values: the effec‐
361            tive user ID, the effective group ID, and the group access list.
362
363            The effective user ID and effective group  ID  are  initially  the
364            process's real user ID and real group ID respectively.  Either may
365            be modified through execution of  a  set-user-ID  or  set-group-ID
366            file (possibly by one its ancestors) (see execve(2)).
367
368            The group access list is an additional set of group ID's used only
369            in determining resource accessibility.   Access  checks  are  per‐
370            formed as described below in ``File Access Permissions''.
371
372       Super-user
373            A  process  is  recognized  as a super-user process and is granted
374            special privileges if its effective user ID is 0.
375
376       Special Processes
377            The processes with a process ID's of 0,  1,  and  2  are  special.
378            Process  0  is  the  scheduler.   Process  1 is the initialization
379            process init, and is the ancestor of every other  process  in  the
380            system.   It  is used to control the process structure.  Process 2
381            is the paging daemon.
382
383       Descriptor
384            An integer assigned by the system when a  file  is  referenced  by
385            open(2)  or  dup(2),  or  when  a  socket  is  created by pipe(2),
386            socket(2) or socketpair(2), which uniquely  identifies  an  access
387            path  to  that  file  or socket from a given process or any of its
388            children.
389
390       File Name
391            Names consisting of up to 255 (MAXNAMELEN) characters may be  used
392            to name an ordinary file, special file, or directory.
393
394            These characters may be selected from the set of all ASCII charac‐
395            ter excluding 0 (null) and the ASCII code  for  /  (slash).   (The
396            parity bit, bit 8, must be 0.)
397
398            Note  that  it  is generally unwise to use *, ?, [ or ] as part of
399            file names because of the special meaning attached to these  char‐
400            acters by the shell.
401
402       Path Name
403            A path name is a null-terminated character string starting with an
404            optional slash (/), followed by zero or more directory names sepa‐
405            rated  by  slashes, optionally followed by a file name.  The total
406            length of a path name must be less than 1024 (MAXPATHLEN)  charac‐
407            ters.
408
409            If  a path name begins with a slash, the path search begins at the
410            root directory.  Otherwise, the search  begins  from  the  current
411            working directory.  A slash by itself names the root directory.  A
412            null pathname refers to the current directory.
413
414       Directory
415            A directory is a special type of file that contains  entries  that
416            are  references  to  other  files.   Directory  entries are called
417            links.  By convention, a directory contains at least two links,  .
418            and  ..,  referred to as dot and dot-dot respectively.  Dot refers
419            to the directory itself and dot-dot refers to  its  parent  direc‐
420            tory.
421
422       Root Directory and Current Working Directory
423            Each  process has associated with it a concept of a root directory
424            and a current working directory for the purpose of resolving  path
425            name  searches.   A  process's root directory need not be the root
426            directory of the root file system.
427
428       File Access Permissions
429            Every file in the file system has a  set  of  access  permissions.
430            These  permissions  are  used in determining whether a process may
431            perform a requested operation on the file (such as opening a  file
432            for  writing).   Access  permissions are established at the time a
433            file is created.  They may be changed at some later  time  through
434            the chmod(2) call.
435
436            File  access  is  broken  down according to whether a file may be:
437            read, written, or executed.  Directory files use the execute  per‐
438            mission to control if the directory may be searched.
439
440            File  access  permissions  are  interpreted  by the system as they
441            apply to three different classes of users: the owner of the  file,
442            those  users  in the file's group, anyone else.  Every file has an
443            independent set of access permissions for each of  these  classes.
444            When  an  access  check  is made, the system decides if permission
445            should be granted by checking the access information applicable to
446            the caller.
447
448            Read,  write, and execute/search permissions on a file are granted
449            to a process if:
450
451            The process's effective user ID is that of the super-user.
452
453            The process's effective user ID matches the user ID of  the  owner
454            of the file and the owner permissions allow the access.
455
456            The  process's effective user ID does not match the user ID of the
457            owner of the file, and either the  process's  effective  group  ID
458            matches  the  group ID of the file, or the group ID of the file is
459            in the process's group access  list,  and  the  group  permissions
460            allow the access.
461
462            Neither  the  effective  user  ID nor effective group ID and group
463            access list of the process match the  corresponding  user  ID  and
464            group  ID  of  the  file,  but the permissions for ``other users''
465            allow access.
466
467            Otherwise, permission is denied.
468
469       Sockets and Address Families
470
471            A socket is an endpoint for communication between processes.  Each
472            socket has queues for sending and receiving data.
473
474            Sockets  are  typed  according to their communications properties.
475            These properties include whether messages sent and received  at  a
476            socket  require  the name of the partner, whether communication is
477            reliable, the format used in naming message recipients, etc.
478
479            Each instance of the system supports  some  collection  of  socket
480            types;  consult  socket(2)  for  more  information about the types
481            available and their properties.
482
483            Each instance of the system supports some number of sets of commu‐
484            nications  protocols.   Each  protocol set supports addresses of a
485            certain format.  An Address Family is the set of addresses  for  a
486            specific  group  of  protocols.  Each socket has an address chosen
487            from the address family in which the socket was created.
488

SEE ALSO

490       intro(3), perror(3)
491
492
493
4944th Berkeley Distribution        May 23, 1986                         INTRO(2)
Impressum