202 lines
6.4 KiB
HTML
202 lines
6.4 KiB
HTML
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML><HEAD><TITLE>Man page of INTRO</TITLE>
|
|
</HEAD><BODY>
|
|
<H1>INTRO</H1>
|
|
Section: Linux Programmer's Manual (2)<BR>Updated: 2019-08-02<BR><A HREF="#index">Index</A>
|
|
<A HREF="/cgi-bin/man/man2html">Return to Main Contents</A><HR>
|
|
|
|
<A NAME="lbAB"> </A>
|
|
<H2>NAME</H2>
|
|
|
|
intro - introduction to system calls
|
|
<A NAME="lbAC"> </A>
|
|
<H2>DESCRIPTION</H2>
|
|
|
|
Section 2 of the manual describes the Linux system calls.
|
|
A system call is an entry point into the Linux kernel.
|
|
Usually, system calls are not invoked directly:
|
|
instead, most system calls have corresponding C library
|
|
wrapper functions which perform the steps required
|
|
(e.g., trapping to kernel mode) in order to invoke
|
|
the system call.
|
|
Thus, making a system call looks the same as invoking a normal
|
|
library function.
|
|
<P>
|
|
|
|
In many cases, the C library wrapper function does nothing more than:
|
|
<DL COMPACT>
|
|
<DT id="1">*<DD>
|
|
copying arguments and the unique system call number to the
|
|
registers where the kernel expects them;
|
|
<DT id="2">*<DD>
|
|
trapping to kernel mode,
|
|
at which point the kernel does the real work of the system call;
|
|
<DT id="3">*<DD>
|
|
setting
|
|
<I>errno</I>
|
|
|
|
if the system call returns an error number when the kernel returns the
|
|
CPU to user mode.
|
|
</DL>
|
|
<P>
|
|
|
|
However, in a few cases, a wrapper function may do rather more than this,
|
|
for example, performing some preprocessing
|
|
of the arguments before trapping to kernel mode,
|
|
or postprocessing of values returned by the system call.
|
|
Where this is the case, the manual pages in Section 2 generally
|
|
try to note the details of both the (usually GNU) C library API
|
|
interface and the raw system call.
|
|
Most commonly, the main DESCRIPTION will focus on the C library interface,
|
|
and differences for the system call are covered in the NOTES section.
|
|
<P>
|
|
|
|
For a list of the Linux system calls, see
|
|
<B><A HREF="/cgi-bin/man/man2html?2+syscalls">syscalls</A></B>(2).
|
|
|
|
<A NAME="lbAD"> </A>
|
|
<H2>RETURN VALUE</H2>
|
|
|
|
On error, most system calls return a negative error number
|
|
(i.e., the negated value of one of the constants described in
|
|
<B><A HREF="/cgi-bin/man/man2html?3+errno">errno</A></B>(3)).
|
|
|
|
The C library wrapper hides this detail from the caller: when a
|
|
system call returns a negative value, the wrapper copies the
|
|
absolute value into the
|
|
<I>errno</I>
|
|
|
|
variable, and returns -1 as the return value of the wrapper.
|
|
<P>
|
|
|
|
The value returned by a successful system call depends on the call.
|
|
Many system calls return 0 on success, but some can return nonzero
|
|
values from a successful call.
|
|
The details are described in the individual manual pages.
|
|
<P>
|
|
|
|
In some cases,
|
|
the programmer must define a feature test macro in order to obtain
|
|
the declaration of a system call from the header file specified
|
|
in the man page SYNOPSIS section.
|
|
(Where required, these feature test macros must be defined before including
|
|
<I>any</I>
|
|
|
|
header files.)
|
|
In such cases, the required macro is described in the man page.
|
|
For further information on feature test macros, see
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7).
|
|
|
|
<A NAME="lbAE"> </A>
|
|
<H2>CONFORMING TO</H2>
|
|
|
|
Certain terms and abbreviations are used to indicate UNIX variants
|
|
and standards to which calls in this section conform.
|
|
See
|
|
<B><A HREF="/cgi-bin/man/man2html?7+standards">standards</A></B>(7).
|
|
|
|
<A NAME="lbAF"> </A>
|
|
<H2>NOTES</H2>
|
|
|
|
<A NAME="lbAG"> </A>
|
|
<H3>Calling directly</H3>
|
|
|
|
In most cases, it is unnecessary to invoke a system call directly,
|
|
but there are times when the Standard C library does not implement
|
|
a nice wrapper function for you.
|
|
In this case, the programmer must manually invoke the system call using
|
|
<B><A HREF="/cgi-bin/man/man2html?2+syscall">syscall</A></B>(2).
|
|
|
|
Historically, this was also possible using one of the _syscall macros
|
|
described in
|
|
<B><A HREF="/cgi-bin/man/man2html?2+_syscall">_syscall</A></B>(2).
|
|
|
|
<A NAME="lbAH"> </A>
|
|
<H3>Authors and copyright conditions</H3>
|
|
|
|
Look at the header of the manual page source for the author(s) and copyright
|
|
conditions.
|
|
Note that these can be different from page to page!
|
|
<A NAME="lbAI"> </A>
|
|
<H2>SEE ALSO</H2>
|
|
|
|
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+_syscall">_syscall</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+syscall">syscall</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?2+syscalls">syscalls</A></B>(2),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+errno">errno</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?3+intro">intro</A></B>(3),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+capabilities">capabilities</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+credentials">credentials</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+feature_test_macros">feature_test_macros</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+mq_overview">mq_overview</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+path_resolution">path_resolution</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+pipe">pipe</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+pty">pty</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+sem_overview">sem_overview</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+shm_overview">shm_overview</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+signal">signal</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+socket">socket</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+standards">standards</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+symlink">symlink</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+sysvipc">sysvipc</A></B>(7),
|
|
|
|
<B><A HREF="/cgi-bin/man/man2html?7+time">time</A></B>(7)
|
|
|
|
<A NAME="lbAJ"> </A>
|
|
<H2>COLOPHON</H2>
|
|
|
|
This page is part of release 5.05 of the Linux
|
|
<I>man-pages</I>
|
|
|
|
project.
|
|
A description of the project,
|
|
information about reporting bugs,
|
|
and the latest version of this page,
|
|
can be found at
|
|
<A HREF="https://www.kernel.org/doc/man-pages/.">https://www.kernel.org/doc/man-pages/.</A>
|
|
<P>
|
|
|
|
<HR>
|
|
<A NAME="index"> </A><H2>Index</H2>
|
|
<DL>
|
|
<DT id="4"><A HREF="#lbAB">NAME</A><DD>
|
|
<DT id="5"><A HREF="#lbAC">DESCRIPTION</A><DD>
|
|
<DT id="6"><A HREF="#lbAD">RETURN VALUE</A><DD>
|
|
<DT id="7"><A HREF="#lbAE">CONFORMING TO</A><DD>
|
|
<DT id="8"><A HREF="#lbAF">NOTES</A><DD>
|
|
<DL>
|
|
<DT id="9"><A HREF="#lbAG">Calling directly</A><DD>
|
|
<DT id="10"><A HREF="#lbAH">Authors and copyright conditions</A><DD>
|
|
</DL>
|
|
<DT id="11"><A HREF="#lbAI">SEE ALSO</A><DD>
|
|
<DT id="12"><A HREF="#lbAJ">COLOPHON</A><DD>
|
|
</DL>
|
|
<HR>
|
|
This document was created by
|
|
<A HREF="/cgi-bin/man/man2html">man2html</A>,
|
|
using the manual pages.<BR>
|
|
Time: 00:05:33 GMT, March 31, 2021
|
|
</BODY>
|
|
</HTML>
|