]>
Commit | Line | Data |
---|---|---|
a209ce80 | 1 | .\" Copyright (C) 2007 Michael Kerrisk <mtk.manpages@gmail.com> |
fea681da | 2 | .\" |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
a209ce80 MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
fea681da | 7 | .\" |
a209ce80 MK |
8 | .\" Permission is granted to copy and distribute modified versions of this |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
fea681da | 12 | .\" |
a209ce80 MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
fea681da | 20 | .\" |
a209ce80 MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da | 24 | .\" |
a209ce80 MK |
25 | .\" 2007-10-23 mtk: moved the _syscallN specific material to the |
26 | .\" new _syscall(2) page, and substantially enhanced and rewrote | |
27 | .\" the remaining material on this page. | |
fea681da | 28 | .\" |
63121bd4 | 29 | .TH INTRO 2 2019-08-02 "Linux" "Linux Programmer's Manual" |
fea681da | 30 | .SH NAME |
f68512e9 | 31 | intro \- introduction to system calls |
fea681da | 32 | .SH DESCRIPTION |
a209ce80 MK |
33 | Section 2 of the manual describes the Linux system calls. |
34 | A system call is an entry point into the Linux kernel. | |
35 | Usually, system calls are not invoked directly: | |
36 | instead, most system calls have corresponding C library | |
37 | wrapper functions which perform the steps required | |
38 | (e.g., trapping to kernel mode) in order to invoke | |
39 | the system call. | |
8e09de4e | 40 | Thus, making a system call looks the same as invoking a normal |
a209ce80 | 41 | library function. |
efeece04 | 42 | .PP |
49bd7f58 MK |
43 | In many cases, the C library wrapper function does nothing more than: |
44 | .IP * 3 | |
45 | copying arguments and the unique system call number to the | |
46 | registers where the kernel expects them; | |
47 | .IP * | |
48 | trapping to kernel mode, | |
1288e3eb | 49 | at which point the kernel does the real work of the system call; |
49bd7f58 MK |
50 | .IP * |
51 | setting | |
52 | .I errno | |
92692952 | 53 | if the system call returns an error number when the kernel returns the |
49bd7f58 | 54 | CPU to user mode. |
dd3568a1 | 55 | .PP |
49bd7f58 MK |
56 | However, in a few cases, a wrapper function may do rather more than this, |
57 | for example, performing some preprocessing | |
1288e3eb | 58 | of the arguments before trapping to kernel mode, |
49bd7f58 MK |
59 | or postprocessing of values returned by the system call. |
60 | Where this is the case, the manual pages in Section 2 generally | |
61 | try to note the details of both the (usually GNU) C library API | |
62 | interface and the raw system call. | |
63 | Most commonly, the main DESCRIPTION will focus on the C library interface, | |
64 | and differences for the system call are covered in the NOTES section. | |
efeece04 | 65 | .PP |
a209ce80 MK |
66 | For a list of the Linux system calls, see |
67 | .BR syscalls (2). | |
68 | .SH RETURN VALUE | |
69 | On error, most system calls return a negative error number | |
70 | (i.e., the negated value of one of the constants described in | |
71 | .BR errno (3)). | |
72 | The C library wrapper hides this detail from the caller: when a | |
73 | system call returns a negative value, the wrapper copies the | |
74 | absolute value into the | |
75 | .I errno | |
76 | variable, and returns \-1 as the return value of the wrapper. | |
efeece04 | 77 | .PP |
a209ce80 | 78 | The value returned by a successful system call depends on the call. |
c7094399 | 79 | Many system calls return 0 on success, but some can return nonzero |
a209ce80 MK |
80 | values from a successful call. |
81 | The details are described in the individual manual pages. | |
efeece04 | 82 | .PP |
a209ce80 MK |
83 | In some cases, |
84 | the programmer must define a feature test macro in order to obtain | |
85 | the declaration of a system call from the header file specified | |
86 | in the man page SYNOPSIS section. | |
e417acb0 MK |
87 | (Where required, these feature test macros must be defined before including |
88 | .I any | |
89 | header files.) | |
a209ce80 MK |
90 | In such cases, the required macro is described in the man page. |
91 | For further information on feature test macros, see | |
92 | .BR feature_test_macros (7). | |
47297adb | 93 | .SH CONFORMING TO |
008f1ecc | 94 | Certain terms and abbreviations are used to indicate UNIX variants |
a209ce80 | 95 | and standards to which calls in this section conform. |
a1d5f77c MK |
96 | See |
97 | .BR standards (7). | |
fea681da | 98 | .SH NOTES |
73d8cece | 99 | .SS Calling directly |
a209ce80 MK |
100 | In most cases, it is unnecessary to invoke a system call directly, |
101 | but there are times when the Standard C library does not implement | |
102 | a nice wrapper function for you. | |
103 | In this case, the programmer must manually invoke the system call using | |
104 | .BR syscall (2). | |
105 | Historically, this was also possible using one of the _syscall macros | |
106 | described in | |
107 | .BR _syscall (2). | |
c634028a | 108 | .SS Authors and copyright conditions |
a209ce80 MK |
109 | Look at the header of the manual page source for the author(s) and copyright |
110 | conditions. | |
111 | Note that these can be different from page to page! | |
47297adb | 112 | .SH SEE ALSO |
4af700b7 MK |
113 | .ad l |
114 | .nh | |
a209ce80 | 115 | .BR _syscall (2), |
fea681da | 116 | .BR syscall (2), |
4af700b7 MK |
117 | .BR syscalls (2), |
118 | .BR errno (3), | |
119 | .BR intro (3), | |
120 | .BR capabilities (7), | |
121 | .BR credentials (7), | |
122 | .BR feature_test_macros (7), | |
123 | .BR mq_overview (7), | |
124 | .BR path_resolution (7), | |
125 | .BR pipe (7), | |
126 | .BR pty (7), | |
127 | .BR sem_overview (7), | |
128 | .BR shm_overview (7), | |
129 | .BR signal (7), | |
4af700b7 | 130 | .BR socket (7), |
2bfa8272 | 131 | .BR standards (7), |
4af700b7 | 132 | .BR symlink (7), |
343cdc5a | 133 | .BR sysvipc (7), |
4af700b7 | 134 | .BR time (7) |