syscall.2: Add some more details to the description of syscall(2)

And add another example of using syscall() to the program example.

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>

syscall.2: fix

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2012-07-13 08:07:19 +02:00
parent 50cebc0485
commit 498a96a239
1 changed files with 16 additions and 2 deletions

View File

@ -48,11 +48,24 @@ syscall \- indirect system call
.fi
.SH DESCRIPTION
.BR syscall ()
performs the system call whose assembly language
is a small library function that invokes
the system call whose assembly language
interface has the specified
.I number
with the specified arguments.
Symbolic constants for system calls can be found in the header file
Employing
.BR syscall ()
is useful, for example,
when invoking a system call that has no wrapper function in the C library.
.BR syscall ()
saves CPU registers before making the system call,
restores the registers upon return from the system call,
and stores any error code returned by the system call in
.BR errno (3)
if an error occurs.
Symbolic constants for system call numbers can be found in the header file
.IR <sys/syscall.h> .
.SH RETURN VALUE
The return value is defined by the system call being invoked.
@ -77,6 +90,7 @@ main(int argc, char *argv[])
pid_t tid;
tid = syscall(SYS_gettid);
tid = syscall(SYS_tgkill, getpid(), tid);
}
.fi
.SH SEE ALSO