1 .\" Copyright (C) 2007 Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .\" 2007-10-23 mtk: moved the _syscallN specific material to the
24 .\" new _syscall(2) page, and substantially enhanced and rewrote
25 .\" the remaining material on this page.
27 .\" Japanese Version Copyright (c) 2008 Akihiro MOTOKI
28 .\" all rights reserved.
29 .\" Translated 2008-02-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
31 .TH INTRO 2 2010-02-03 "Linux" "Linux Programmer's Manual"
34 .\"O intro \- Introduction to system calls
35 intro \- ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÎÀâÌÀ
38 .\"O Section 2 of the manual describes the Linux system calls.
39 .\"O A system call is an entry point into the Linux kernel.
40 .\"O Usually, system calls are not invoked directly:
41 .\"O instead, most system calls have corresponding C library
42 .\"O wrapper functions which perform the steps required
43 .\"O (e.g., trapping to kernel mode) in order to invoke
45 .\"O Thus, making a system call looks the same as invoking a normal
46 .\"O library function.
47 ¥Þ¥Ë¥å¥¢¥ë¤Î 2 ¾Ï¤Ç¤Ï Linux ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤ë¡£
48 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ï Linux ¥«¡¼¥Í¥ë¤Ø¤Î¥¨¥ó¥È¥ê¥Ý¥¤¥ó¥È¤Ç¤¢¤ë¡£
49 Ä̾ï¤Ï¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÏľÀܵ¯Æ°¤µ¤ì¤ëÌõ¤Ç¤Ï¤Ê¤¯¡¢
50 ¤Û¤È¤ó¤É¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Ë¤ÏÂбþ¤¹¤ë C ¥é¥¤¥Ö¥é¥ê¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤¬¤¢¤ê¡¢
51 ¤½¤Î¥é¥Ã¥Ñ¡¼´Ø¿ô¤¬¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¸Æ¤Ó½Ð¤¹¤Î¤ËɬÍפʽèÍý¤ò¼Â¹Ô¤¹¤ë¡£
52 ¤½¤Î¤¿¤á¡¢¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¸Æ¤Ó½Ð¤¹¤Î¤ÏÄ̾ï¤Î¥é¥¤¥Ö¥é¥ê´Ø¿ô¤ò¸Æ¤Ó½Ð¤¹¤Î¤È
55 .\"O For a list of the Linux system calls, see
56 .\"O .BR syscalls (2).
57 Linux ¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¥ê¥¹¥È¤Ë¤Ä¤¤¤Æ¤Ï
62 .\"O On error, most system calls return a negative error number
63 .\"O (i.e., the negated value of one of the constants described in
65 .\"O The C library wrapper hides this detail from the caller: when a
66 .\"O system call returns a negative value, the wrapper copies the
67 .\"O absolute value into the
69 .\"O variable, and returns \-1 as the return value of the wrapper.
70 ¥¨¥é¡¼¤Î¾ì¹ç¡¢¤Û¤È¤ó¤É¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÏÉé¤Î¥¨¥é¡¼ÈÖ¹æ¤òÊÖ¤¹
73 ¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ëÄê¿ô¤Î¤¤¤º¤ì¤«¤òÉé¤Ë¤·¤¿ÃͤòÊÖ¤¹)¡£
74 C ¥é¥¤¥Ö¥é¥ê¤Î¥é¥Ã¥Ñ¡¼¤Ï¸Æ¤Ó½Ð¤·¸µ¤«¤é¤³¤¦¤·¤¿¾ÜºÙ¤ò±£Ê䷤Ƥ¤¤ë¡£
75 ¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬Éé¤ÎÃͤòÊÖ¤·¤¿¾ì¹ç¡¢¥é¥Ã¥Ñ¡¼¤ÏÀäÂÐÃͤò
77 ÊÑ¿ô¤Ë¥³¥Ô¡¼¤·¡¢¥é¥Ã¥Ñ¡¼¤ÎÊÖ¤êÃͤȤ·¤Æ \-1 ¤òÊÖ¤¹¡£
79 .\"O The value returned by a successful system call depends on the call.
80 .\"O Many system calls return 0 on success, but some can return nonzero
81 .\"O values from a successful call.
82 .\"O The details are described in the individual manual pages.
83 À®¸ù»þ¤Ë¥·¥¹¥Æ¥à¥³¡¼¥ë¤¬ÊÖ¤¹Ãͤϥ·¥¹¥Æ¥à¥³¡¼¥ë¤Ë¤è¤ê°Û¤Ê¤ë¡£
84 ¿¤¯¤Î¥·¥¹¥Æ¥à¥³¡¼¥ë¤ÏÀ®¸ù»þ¤Ë 0 ¤òÊÖ¤¹¤¬¡¢
85 À®¸ù»þ¤Ë 0 °Ê³°¤ÎÃͤòÊÖ¤¹¥·¥¹¥Æ¥à¥³¡¼¥ë¤â¤¢¤ë¡£
86 ¾ÜºÙ¤Ï¸Ä¡¹¤Î¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë¡£
89 .\"O the programmer must define a feature test macro in order to obtain
90 .\"O the declaration of a system call from the header file specified
91 .\"O in the man page SYNOPSIS section.
92 .\"O In such cases, the required macro is described in the man page.
93 .\"O For further information on feature test macros, see
94 .\"O .BR feature_test_macros (7).
95 ¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤Î¡Ö½ñ¼°¡×¤ÎÀá¤Ëµ¬Äꤵ¤ì¤¿¥Ø¥Ã¥À¥Õ¥¡¥¤¥ë¤«¤é´Ø¿ô¤ÎÄêµÁ¤ò
96 ÆÀ¤ë¤¿¤á¤Ë¡¢¥×¥í¥°¥é¥Þ¤¬µ¡Ç½¸¡ºº¥Þ¥¯¥í¤òÄêµÁ¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¾ì¹ç¤¬¤¢¤ë¡£
97 ¤³¤Î¤è¤¦¤Ê¾ì¹ç¤Ë¤Ï¡¢É¬Íפʥޥ¯¥í¤¬¥Þ¥Ë¥å¥¢¥ë¥Ú¡¼¥¸¤ÇÀâÌÀ¤µ¤ì¤Æ¤¤¤ë¡£
98 µ¡Ç½¸¡ºº¥Þ¥¯¥í¤Î¤µ¤é¤Ê¤ë¾ðÊó¤Ë¤Ä¤¤¤Æ¤Ï¡¢
99 .BR feature_test_macros (7)
101 .\"O .SH "CONFORMING TO"
103 .\"O Certain terms and abbreviations are used to indicate Unix variants
104 .\"O and standards to which calls in this section conform.
106 .\"O .BR standards (7).
107 ¤³¤Î¾Ï¤Î´Ø¿ô¤¬½àµò¤¹¤ë Unix ¥·¥¹¥Æ¥à¤äɸ½à¤ò¼¨¤¹¤Î¤Ë¤¤¤¯¤Ä¤«¤Îñ¸ì¤äά¹æ¤¬
113 .\"O .SS "Calling Directly"
115 .\"O In most cases, it is unnecessary to invoke a system call directly,
116 .\"O but there are times when the Standard C library does not implement
117 .\"O a nice wrapper function for you.
118 .\"O In this case, the programmer must manually invoke the system call using
119 .\"O .BR syscall (2).
120 .\"O Historically, this was also possible using one of the _syscall macros
122 .\"O .BR _syscall (2).
123 ¤Û¤È¤ó¤É¤Î¾ì¹ç¡¢Ä¾ÀÜ¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¸Æ¤Ó½Ð¤¹É¬ÍפϤʤ¤¤¬¡¢
124 ¾ì¹ç¤Ë¤è¤Ã¤Æ¤Ïɸ½à C ¥é¥¤¥Ö¥é¥ê¤ËŬÀڤʴؿô¤¬¼ÂÁõ¤µ¤ì¤Æ¤¤¤Ê¤¤¤³¤È¤â¤¢¤ë¡£
125 ¤³¤Î¤è¤¦¤Ê¾ì¹ç¤Ï¡¢¥×¥í¥°¥é¥Þ¤Ï
127 ¤ò»È¤Ã¤Æ¡¢¼«Ê¬¤Ç¥·¥¹¥Æ¥à¥³¡¼¥ë¤ò¸Æ¤Ó½Ð¤µ¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
130 ¥Þ¥¯¥í¤Î°ì¤Ä¤ò»È¤Ã¤Æ¥·¥¹¥Æ¥à¥³¡¼¥ë¤Î¸Æ¤Ó½Ð¤¹¤³¤È¤â¤Ç¤¤¿¡£
131 .\"O .SS Authors and Copyright Conditions
133 .\"O Look at the header of the manual page source for the author(s) and copyright
135 .\"O Note that these can be different from page to page!
136 Ãø¼Ô¤ÈÃøºî¸¢ (copyright) ¤Ë´Ø¤·¤Æ¤Ï³Æ¥Þ¥Ë¥å¥¢¥ë¡¦¥Ú¡¼¥¸¤Î¥½¡¼¥¹¤Î¥Ø¥Ã¥À¤ò
137 ¸«¤ë¤³¤È¡£¤³¤ì¤é¤Ï¥Ú¡¼¥¸¤´¤È¤Ë°Û¤Ã¤Æ¤¤¤ë¡£
143 .BR feature_test_macros (7),