1INTRO(2)                   Linux Programmer's Manual                  INTRO(2)
2
3
4

NAME

6       intro - introduction to system calls
7

DESCRIPTION

9       Section  2  of  the  manual describes the Linux system calls.  A system
10       call is an entry point into the Linux kernel.   Usually,  system  calls
11       are not invoked directly: instead, most system calls have corresponding
12       C library wrapper functions which perform  the  steps  required  (e.g.,
13       trapping  to  kernel  mode)  in order to invoke the system call.  Thus,
14       making a system call looks the same as invoking a normal library  func‐
15       tion.
16
17       In many cases, the C library wrapper function does nothing more than:
18
19       *  copying arguments and the unique system call number to the registers
20          where the kernel expects them;
21
22       *  trapping to kernel mode, at which point the  kernel  does  the  real
23          work of the system call;
24
25       *  setting  errno  if  the system call returns an error number when the
26          kernel returns the CPU to user mode.
27
28       However, in a few cases, a wrapper function may  do  rather  more  than
29       this,  for  example,  performing  some  preprocessing  of the arguments
30       before trapping to kernel mode, or postprocessing of values returned by
31       the system call.  Where this is the case, the manual pages in Section 2
32       generally try to note the details of both the (usually GNU)  C  library
33       API  interface  and  the  raw  system  call.   Most  commonly, the main
34       DESCRIPTION will focus on the C library interface, and differences  for
35       the system call are covered in the NOTES section.
36
37       For a list of the Linux system calls, see syscalls(2).
38

RETURN VALUE

40       On  error,  most system calls return a negative error number (i.e., the
41       negated value of one of the constants described in  errno(3)).   The  C
42       library  wrapper  hides this detail from the caller: when a system call
43       returns a negative value, the wrapper copies the  absolute  value  into
44       the errno variable, and returns -1 as the return value of the wrapper.
45
46       The  value  returned  by  a successful system call depends on the call.
47       Many system calls return 0 on success, but some can return nonzero val‐
48       ues  from a successful call.  The details are described in the individ‐
49       ual manual pages.
50
51       In some cases, the programmer must define a feature test macro in order
52       to  obtain the declaration of a system call from the header file speci‐
53       fied in the man page SYNOPSIS section.  (Where required, these  feature
54       test  macros  must  be  defined before including any header files.)  In
55       such cases, the required macro is described in the man page.  For  fur‐
56       ther information on feature test macros, see feature_test_macros(7).
57

CONFORMING TO

59       Certain  terms and abbreviations are used to indicate UNIX variants and
60       standards to which calls in this section conform.  See standards(7).
61

NOTES

63   Calling directly
64       In most cases, it is unnecessary to invoke a system call directly,  but
65       there  are  times when the Standard C library does not implement a nice
66       wrapper function for you.  In this case, the programmer  must  manually
67       invoke  the  system call using syscall(2).  Historically, this was also
68       possible using one of the _syscall macros described in _syscall(2).
69
70   Authors and copyright conditions
71       Look at the header of the manual page  source  for  the  author(s)  and
72       copyright  conditions.   Note  that these can be different from page to
73       page!
74

SEE ALSO

76       _syscall(2), syscall(2), syscalls(2), errno(3), intro(3),
77       capabilities(7), credentials(7), feature_test_macros(7),
78       mq_overview(7), path_resolution(7), pipe(7), pty(7), sem_overview(7),
79       shm_overview(7), signal(7), socket(7), standards(7), symlink(7),
80       sysvipc(7), time(7)
81

COLOPHON

83       This page is part of release 5.02 of the Linux man-pages project.  A
84       description of the project, information about reporting bugs, and the
85       latest version of this page, can be found at
86       https://www.kernel.org/doc/man-pages/.
87
88
89
90Linux                             2019-08-02                          INTRO(2)
Impressum