1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (C) 2002 Michael Kerrisk <mtk.manpages@gmail.com>
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" FIXME . Add an example to this page
27 .\" Japanese Version Copyright (c) 2002 Akihiro MOTOKI, all rights reserved.
28 .\" Translated Mon Feb 2 2003 by Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
29 .\" Updated 2009-02-23, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>, LDP v3.19
31 .TH SHM_OPEN 3 2009-02-25 "Linux" "Linux Programmer's Manual"
33 shm_open, shm_unlink \- POSIX ¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ÎºîÀ®/¥ª¡¼¥×¥ó¡¢
36 .B #include <sys/mman.h>
38 .BR "#include <sys/stat.h>" " /* mode Äê¿ôÍÑ */"
40 .BR "#include <fcntl.h>" " /* O_* Äê¿ô¤ÎÄêµÁÍÑ */"
42 .BI "void * shm_open(const char *" name ", int " oflag ", mode_t " mode );
44 .BI "int shm_unlink(const char *" name );
46 \fI\-lrt\fP ¤Ç¥ê¥ó¥¯¤¹¤ë¡£
49 ¤Ï¡¢POSIX ¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ò¿·µ¬¤ËºîÀ®/¥ª¡¼¥×¥ó¤·¤¿¤ê¡¢
50 ¤¹¤Ç¤Ë¸ºß¤¹¤ë¥ª¥Ö¥¸¥§¥¯¥È¤ò¥ª¡¼¥×¥ó¤·¤¿¤ê¤¹¤ë¡£
51 POSIX ¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Ï¡¢¼ÂºÝ¤Ë¤Ï¡¢´Ø·¸¤Î¤Ê¤¤¥×¥í¥»¥¹¤¬
52 ¶¦Í¥á¥â¥ê¤ÎƱ¤¸Îΰè¤ò
54 ¤¹¤ë¤¿¤á¤Ë»ÈÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤ë¼êÃʤǤ¢¤ë¡£
56 ¤Ï¡¢µÕ¤ÎÁàºî¡¢¤Ä¤Þ¤ê°ÊÁ°¤Ë
58 ¤ÇºîÀ®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Îºï½ü¤ò¹Ô¤¦¡£
65 ¤ÇºîÀ®¤·¤¿¤ê¥ª¡¼¥×¥ó¤·¤¿¤ê¤¹¤ë¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ò»ØÄꤹ¤ë¡£
66 °Ü¿¢À¤ò»ý¤¿¤»¤ë¤¿¤á¤Ë¤Ï¡¢¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Ï
68 ¤È¤¤¤¦·Á¼°¤Î̾Á°¤Ç¼±Ê̤·¡¢
71 (¤¹¤Ê¤ï¤Á 255) ʸ»ú¤Î NULL ½ªÃ¼¤µ¤ì¤¿Ê¸»úÎó¤Ç¡¢
72 .\" glibc allows the initial slash to be omitted, and makes
73 .\" multiple initial slashes equivalent to a single slash.
74 .\" This differs from the implementation of POSIX message queues.
75 ¥¹¥é¥Ã¥·¥å¤Ç»Ï¤Þ¤ê¡¢¥¹¥é¥Ã¥·¥å°Ê³°¤Îʸ»ú¤¬ 1 ʸ»ú°Ê¾å³¤¯·Á¼°
77 .\" glibc allows subdirectory components in the name, in which
78 .\" case the subdirectory must exist under /dev/shm, and allow the
79 .\" required permissions if a user wants to create a shared memory
80 .\" object in that subdirectory.
87 ¤Î¤¤¤º¤ì¤«°ìÊý¤È¡¢°Ê²¼¤Ë½Ò¤Ù¤ë¾¤Î¥Õ¥é¥°¤ÎÏÀÍýϤò¤È¤Ã¤¿¤â¤Î
91 Æɤ߽Ф·¥¢¥¯¥»¥¹ÍѤ˥ª¥Ö¥¸¥§¥¯¥È¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£
92 ¤³¤Î¥Õ¥é¥°¤ò»ØÄꤷ¤Æ¥ª¡¼¥×¥ó¤µ¤ì¤¿¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Ï¡¢
93 Æɤ߽Ф· (\fBPROT_READ\fP) ¥¢¥¯¥»¥¹¤Ç¤Î¤ß
98 Æɤ߽ñ¤¥¢¥¯¥»¥¹ÍѤ˥ª¥Ö¥¸¥§¥¯¥È¤ò¥ª¡¼¥×¥ó¤¹¤ë¡£
101 ¸ºß¤·¤Ê¤¤¾ì¹ç¡¢¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤òºîÀ®¤¹¤ë¡£
102 ¥ª¥Ö¥¸¥§¥¯¥È¤Î¥æ¡¼¥¶¤È¥°¥ë¡¼¥×¤Î½ê͸¢¤Ï¡¢
103 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤ÎÂбþ¤¹¤ë¼Â¸ú ID ¤¬»È¤ï¤ì¡¢
104 .\" ËÜÅö¤Ï¡¢Linux ¤Ç¤Ï¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à ID ¤¬»È¤ï¤ì¤ë¤Î¤À¤¬¡¢
105 .\" ¤½¤ÎÃͤϤۤȤó¤É¤¤¤Ä¤â¼Â¸ú ID ¤ÈƱ¤¸¤Ç¤¢¤ë¡£ (MTK, Jul 05)
106 ¥ª¥Ö¥¸¥§¥¯¥È¤Îµö²Ä¥Ó¥Ã¥È¤Ï
108 ¤Î²¼°Ì 9 ¥Ó¥Ã¥È¤Ë´ð¤Å¤¤¤ÆÀßÄꤵ¤ì¤ë¡£¤¿¤À¤·¡¢
109 ¥Õ¥¡¥¤¥ë¥â¡¼¥ÉºîÀ®¥Þ¥¹¥¯
111 »²¾È) ¤ËÀßÄꤵ¤ì¤Æ¤¤¤ëÃͤϡ¢¿·µ¬¥ª¥Ö¥¸¥§¥¯¥È¤Ë´Ø¤·¤Æ¤Ï¥¯¥ê¥¢¤µ¤ì¤ë¡£
113 ¤òÄêµÁ¤¹¤ë¤¿¤á¤Ë»ÈÍѤǤ¤ë¥Þ¥¯¥íÄê¿ô(·²)¤Ï
116 (¤³¤ì¤é¤ÎÄê¿ô¤Î¥·¥ó¥Ü¥ëÄêµÁ¤Ï
118 ¤Î¥¤¥ó¥¯¥ë¡¼¥É¤Ë¤è¤êÆÀ¤é¤ì¤ë)¡£
120 ¿·µ¬¤ËºîÀ®¤µ¤ì¤¿¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ÏŤµ 0 ¤Ç½é´ü²½¤µ¤ì¤ë¡£
121 ¥ª¥Ö¥¸¥§¥¯¥È¤ÎÂ礤µ¤Ï
124 ¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤È¤·¤Æ¿·µ¬¤Ë³ÎÊݤµ¤ì¤¿¥Ð¥¤¥È¤Ï¼«Æ°Åª¤Ë
129 ¤¬°ì½ï¤Ë»ØÄꤵ¤ì¤Æ¤ª¤ê¡¢
131 ¤Ç»ØÄꤵ¤ì¤¿¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤¬´û¤Ë¸ºß¤·¤¿¾ì¹ç¡¢
133 ¥ª¥Ö¥¸¥§¥¯¥È¤Î¸ºß³Îǧ¤È¡¢Â¸ºß¤·¤Ê¤«¤Ã¤¿¾ì¹ç¤Î¥ª¥Ö¥¸¥§¥¯¥ÈºîÀ®¤Ï¡¢
134 ɬ¤º°ìÏ¢¤ÎÁàºî¤È¤·¤Æ¼Â¹Ô¤µ¤ì¤ë (performed atomically)¡£
137 ¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤¬¤¹¤Ç¤Ë¸ºß¤·¤¿¾ì¹ç¡¢
138 ¤½¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ò 0 ¥Ð¥¤¥È¤ËÀÚ¤êµÍ¤á¤ë¡£
140 ¤³¤ì¤é¤Î¥Õ¥é¥°ÃͤÎÄêµÁ¤Ï
142 ¤Î¥¤¥ó¥¯¥ë¡¼¥É¤Ë¤è¤êÆÀ¤é¤ì¤ë¡£
144 À®¸ù¤·¤Æ´°Î»¤·¤¿¾ì¹ç¡¢
146 ¤Ï¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ò»²¾È¤¹¤ë¿·¤·¤¤¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£
147 ¤³¤Î¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¡¢¤½¤Î¥×¥í¥»¥¹Æâ¤Ç²áµî¤Ë¥ª¡¼¥×¥ó¤µ¤ì¤Æ¤¤¤Ê¤¤
148 ¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ÎÃæ¤ÇºÇ¤â¾®¤µ¤Ê¿ô¤Ë¤Ê¤ë¤³¤È¤¬Êݾڤµ¤ì¤ë¡£
152 ¤ò»²¾È) ¤¬¡¢¤³¤Î¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ËÀßÄꤵ¤ì¤ë¡£
154 Ä̾¤³¤ì¤é¤Î¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤Ï¡¢¤³¤Î¸å³¤±¤Æ¼Â¹Ô¤µ¤ì¤ë
156 (¿·µ¬¤ËºîÀ®¤µ¤ì¤¿¥ª¥Ö¥¸¥§¥¯¥È¤Î¾ì¹ç¤Î¤ß) ¤È
158 ¤Î¸Æ¤Ó½Ð¤·¤Ë»ÈÍѤµ¤ì¤ë¡£
160 ¤ò¸Æ¤Ó½Ð¤·¤¿¸å¤Ï¡¢¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤ò¥¯¥í¡¼¥º¤·¤Æ¤â¤è¤¯¡¢
161 ¥¯¥í¡¼¥º¤·¤Æ¤â¥á¥â¥ê¡¦¥Þ¥Ã¥Ô¥ó¥°¤Ë±Æ¶Á¤òÍ¿¤¨¤ë¤³¤È¤Ï¤Ê¤¤¡£
167 ¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È̾¤òºï½ü¤·¡¢¤¹¤Ù¤Æ¤Î¥×¥í¥»¥¹¤¬½èÍýÂоݤÎ
168 ¥ª¥Ö¥¸¥§¥¯¥È¤ò¥¢¥ó¥Þ¥Ã¥×¤·¤¿»þÅÀ¤Ç¥ª¥Ö¥¸¥§¥¯¥È¤Î³ä¤êÅö¤Æ¤ò²ò½ü¤·¡¢
169 Âбþ¤¹¤ë¥á¥â¥êÎΰè¤ÎÆâÍƤòÇË´þ¤¹¤ë¡£
173 ¤ò»ý¤Ä¥ª¥Ö¥¸¥§¥¯¥È¤ËÂФ·¤Æ
177 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤¤¾ì¹ç) ¼ºÇÔ¤¹¤ë¡£
179 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¾ì¹ç¡¢¿·¤·¤¯Ê̤Υª¥Ö¥¸¥§¥¯¥È¤¬ºîÀ®¤µ¤ì¤ë)¡£
183 ¤ÏÈóÉé¤Î¥Õ¥¡¥¤¥ë¡¦¥Ç¥£¥¹¥¯¥ê¥×¥¿¤òÊÖ¤¹¡£
188 ¤Ï¡¢À®¸ù¤·¤¿¾ì¹ç 0 ¤ò¡¢¥¨¥é¡¼¤¬µ¯¤³¤Ã¤¿¾ì¹ç \-1 ¤òÊÖ¤¹¡£
190 ¼ºÇÔ¤·¤¿¾ì¹ç¡¢¥¨¥é¡¼¤Î¸¶°ø¤ò¼¨¤¹¤¿¤á
194 ¤ËÀßÄꤵ¤ì¤ëÃͤϰʲ¼¤ÎÄ̤ê¤Ç¤¢¤ë:
197 ¶¦Í¥á¥â¥ê¥ª¥Ö¥¸¥§¥¯¥È¤ò
208 ¤¹¤ë¸¢¸Â¤¬¤Ê¤«¤Ã¤¿¡£¤â¤·¤¯¤Ï¡¢
210 ¤¬»ØÄꤵ¤ì¤¿¤¬¡¢¸Æ¤Ó½Ð¤·¸µ¤Ë¤Ï¤½¤Î¥ª¥Ö¥¸¥§¥¯¥È¤ËÂФ¹¤ë½ñ¤¹þ¤ß¸¢¸Â¤¬
221 ¤Ç»ØÄꤵ¤ì¤¿¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤¬´û¤Ë¸ºß¤·¤¿¡£
227 °ú¤¿ô¤¬ÉÔÀµ¤Ç¤¢¤Ã¤¿¡£
230 ¥×¥í¥»¥¹¤¬¥ª¡¼¥×¥ó²Äǽ¤Ê¥Õ¥¡¥¤¥ë¿ô¤Î¾å¸Â¤Ë¤¹¤Ç¤Ë㤷¤Æ¤¤¤¿¡£
239 ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Ç¥ª¡¼¥×¥ó¤Ç¤¤ë¥Õ¥¡¥¤¥ë¿ô¤Î¾å¸Â¤Ë㤷¤¿¡£
248 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤Ê¤«¤Ã¤¿¡£
257 ¤³¤ì¤é¤Î´Ø¿ô¤Ï glibc 2.2 °Ê¹ß¤ÇÄ󶡤µ¤ì¤Æ¤¤¤ë¡£
261 POSIX.1-2001 ¤Ë¤Ï¡¢¿·µ¬¤ËºîÀ®¤µ¤ì¤ë¶¦Í¥á¥â¥ê¥ª¥Ö¥¸¥§¥¯¥È¤Î¥°¥ë¡¼¥×½ê͸¢¤Ï¡¢
262 ¸Æ¤Ó½Ð¤·¸µ¥×¥í¥»¥¹¤Î¼Â¸ú¥°¥ë¡¼¥× ID ¤« ¡Ö¥·¥¹¥Æ¥à¤Î¥Ç¥Õ¥©¥ë¥È¤Î¥°¥ë¡¼¥× ID¡×
263 ¤Î¤É¤Á¤é¤«¤ËÀßÄꤵ¤ì¤ë¡¢¤È½ñ¤«¤ì¤Æ¤¤¤ë¡£
270 ¤¬°ì½ï¤Ë»ØÄꤵ¤ì¤¿¾ì¹ç¤ÎÆ°ºî¤ò̤ÄêµÁ¤Ë¤·¤Æ¤¤¤ë¡£Linux ¤Ç¤Ï¡¢
271 ´û¸¤Î¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤ËÂФ¹¤ëÀÚ¤êµÍ¤á (truncate) ¤ÏÀ®¸ù¤¹¤ë¡£
272 ¤·¤«¤·¡¢Â¾¤Î UNIX ¥·¥¹¥Æ¥à¤Ç¤âƱ¤¸¤Ç¤¢¤ë¤È¤Ï¸Â¤é¤Ê¤¤¡£
274 Linux 2.4 ¤Ë¤ª¤±¤ë POSIX ¶¦Í¥á¥â¥ê¡¦¥ª¥Ö¥¸¥§¥¯¥È¤Î¼ÂÁõ¤Ï
275 ÀìÍѤΥե¡¥¤¥ë¥·¥¹¥Æ¥à¤ò»ÈÍѤ¹¤ë¡£¤½¤Î¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤ÏÄ̾ï