1 .\" Copyright (c) 1993 Luigi P. Bai (lpb@softint.com) July 28, 1993
2 .\" and Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
3 .\" and Copyright 2004, 2005 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 .\" Modified 1993-07-28, Rik Faith <faith@cs.unc.edu>
26 .\" Modified 1993-11-28, Giorgio Ciucci <giorgio@crcc.it>
27 .\" Modified 1997-01-31, Eric S. Raymond <esr@thyrsus.com>
28 .\" Modified 2001-02-18, Andries Brouwer <aeb@cwi.nl>
29 .\" Modified 2002-01-05, 2004-05-27, 2004-06-17,
30 .\" Michael Kerrisk <mtk.manpages@gmail.com>
31 .\" Modified 2004-10-11, aeb
32 .\" Modified, Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
33 .\" Language and formatting clean-ups
34 .\" Updated shmid_ds structure definitions
35 .\" Added information on SHM_DEST and SHM_LOCKED flags
36 .\" Noted that CAP_IPC_LOCK is not required for SHM_UNLOCK
37 .\" since kernel 2.6.9
38 .\" Modified, 2004-11-25, mtk, notes on 2.6.9 RLIMIT_MEMLOCK changes
39 .\" 2005-04-25, mtk -- noted aberrant Linux behavior w.r.t. new
40 .\" attaches to a segment that has already been marked for deletion.
41 .\" 2005-08-02, mtk: Added IPC_INFO, SHM_INFO, SHM_STAT descriptions.
43 .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
44 .\" all rights reserved.
45 .\" Translated 1997-03-01, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
46 .\" Updated & Modified 2001-06-13, Yuichi SATO <ysato@h4.dion.ne.jp>
47 .\" Updated & Modified 2005-01-05, Yuichi SATO <ysato444@yahoo.co.jp>
48 .\" Updated & Modified 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
49 .\" Updated & Modified 2005-10-08, Akihiro MOTOKI
50 .\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36
52 .\"WORD: shared memory ¶¦Í¥á¥â¥ê
53 .\"WORD: segment ¥»¥°¥á¥ó¥È
55 .\"WORD: group ¥°¥ë¡¼¥×
56 .\"WORD: creator ºîÀ®¼Ô
57 .\"WORD: super-user ¥¹¡¼¥Ñ¡¼¡¦¥æ¡¼¥¶¡¼
60 .\"WORD: swap ¥¹¥ï¥Ã¥×
61 .\"WORD: identifier ¼±ÊÌ»Ò
62 .\"WORD: member ¥á¥ó¥Ð¡¼
63 .\"WORD: feature test macro µ¡Ç½¸¡ºº¥Þ¥¯¥í
65 .TH SHMCTL 2 2008-08-07 "Linux" "Linux Programmer's Manual"
68 .\"O shmctl \- shared memory control
69 shmctl \- ¶¦Í¥á¥â¥ê (shared memory) ¤òÀ©¸æ¤¹¤ë
73 .B #include <sys/ipc.h>
75 .B #include <sys/shm.h>
77 .BI "int shmctl(int " shmid ", int " cmd ", struct shmid_ds *" buf );
82 .\"O performs the control operation specified by
84 .\"O on the shared memory segment whose identifier is given in
89 ¤Î¶¦Í¥á¥â¥ê¡¦¥»¥°¥á¥ó¥È¤ËÂФ·¤Æ
91 ¤Ç»Ø¼¨¤·¤¿À©¸æÌ¿Îá¤ò¼Â¹Ô¤¹¤ë¡£
95 .\"O argument is a pointer to a \fIshmid_ds\fP structure,
96 .\"O defined in \fI<sys/shm.h>\fP as follows:
98 °ú¤¿ô¤Ï¡¢ \fIshmid_ds\fP ¹½Â¤ÂΤؤΥݥ¤¥ó¥¿¤Ç¤¢¤ë¡£
99 ¤³¤Î¹½Â¤ÂÎ¤Ï \fI<sys/shm.h>\fP ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë
104 .\"O struct ipc_perm shm_perm; /* Ownership and permissions */
105 struct ipc_perm shm_perm; /* ½ê͸¢¤Èµö²Ä */
106 .\"O size_t shm_segsz; /* Size of segment (bytes) */
107 size_t shm_segsz; /* ¥»¥°¥á¥ó¥È¤Î¥µ¥¤¥º (¥Ð¥¤¥È) */
108 .\"O time_t shm_atime; /* Last attach time */
109 time_t shm_atime; /* ºÇ¸å¤ÎÉղà (attach) ¤Î»þ¹ï */
110 .\"O time_t shm_dtime; /* Last detach time */
111 time_t shm_dtime; /* ºÇ¸å¤ÎʬΥ (detach) ¤Î»þ¹ï */
112 .\"O time_t shm_ctime; /* Last change time */
113 time_t shm_ctime; /* ºÇ¸å¤ËÊѹ¹¤¬¹Ô¤ï¤ì¤¿»þ¹ï */
114 .\"O pid_t shm_cpid; /* PID of creator */
115 pid_t shm_cpid; /* ºîÀ®¼Ô (creator) ¤Î PID */
116 .\"O pid_t shm_lpid; /* PID of last shmat(2)/shmdt(2) */
117 pid_t shm_lpid; /* ºÇ¸å¤Î shmat(2)/shmdt(2) ¤Î PID */
118 .\"O shmatt_t shm_nattch; /* No. of current attaches */
119 shmatt_t shm_nattch; /* ¸½ºßÉղ䵤ì¤Æ¤¤¤ë¿ô */
127 .\"O structure is defined in \fI<sys/ipc.h>\fP as follows
128 .\"O (the highlighted fields are settable using
131 ¹½Â¤ÂÎ¤Ï \fI<sys/ipc.h>\fP ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ë
132 (¶¯Ä´¤µ¤ì¤¿¥Õ¥£¡¼¥ë¥É¤Ï
134 ¤ò»È¤Ã¤ÆÀßÄê²Äǽ¤Ç¤¢¤ë):
139 .\"O key_t __key; /* Key supplied to shmget(2) */
140 .\"O uid_t \fBuid\fP; /* Effective UID of owner */
141 .\"O gid_t \fBgid\fP; /* Effective GID of owner */
142 .\"O uid_t cuid; /* Effective UID of creator */
143 .\"O gid_t cgid; /* Effective GID of creator */
144 .\"O unsigned short \fBmode\fP; /* \fBPermissions\fP + SHM_DEST and
145 .\"O SHM_LOCKED flags */
146 .\"O unsigned short __seq; /* Sequence number */
147 key_t __key; /* shmget(2) ¤ËÍ¿¤¨¤é¤ì¤ë¥¡¼ */
148 uid_t \fBuid\fP; /* ½êͼԤμ¸ú UID */
149 gid_t \fBgid\fP; /* ½êͼԤμ¸ú GID */
150 uid_t cuid; /* ºîÀ®¼Ô¤Î¼Â¸ú UID */
151 gid_t cgid; /* ºîÀ®¼Ô¤Î¼Â¸ú GID */
152 unsigned short \fBmode\fP; /* \fBµö²Ä\fP + SHM_DEST ¤È
154 unsigned short __seq; /* ¥·¡¼¥±¥ó¥¹ÈÖ¹æ */
159 .\"O Valid values for
163 ¤È¤·¤Æ͸ú¤ÊÃͤϰʲ¼¤ÎÄ̤ê:
167 .\"O Copy information from the kernel data structure associated with
171 .\"O structure pointed to by \fIbuf\fP.
173 ¤Ë´ØÏ¢¤Å¤±¤é¤ì¤¿¥«¡¼¥Í¥ë¥Ç¡¼¥¿¹½Â¤ÂΤξðÊó¤ò
177 .\"O The caller must have read permission on the
178 .\"O shared memory segment.
179 ¸Æ¤Ó½Ð¤·¸µ¤Ï¶¦Í¥á¥â¥ê¡¦¥»¥°¥á¥ó¥È¤ËÂФ¹¤ë
180 Æɤ߹þ¤ßµö²Ä¤ò»ý¤¿¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
183 .\"O Write the values of some members of the
185 .\"O structure pointed to by
187 .\"O to the kernel data structure associated with this shared memory segment,
188 .\"O updating also its
194 ¹½Â¤ÂΤΤ¤¤¯¤Ä¤«¤Î¥á¥ó¥Ð¡¼¤ÎÃͤò¡¢
195 ¤³¤Î¶¦Í¥á¥â¥ê¡¦¥»¥°¥á¥ó¥È¤Ë´ØÏ¢¤Å¤±¤é¤ì¤¿¥«¡¼¥Í¥ë¥Ç¡¼¥¿¹½Â¤ÂΤ˽ñ¤¹þ¤ß¡¢
198 .\"O The following fields can be changed:
199 .\"O \fIshm_perm.uid\fP, \fIshm_perm.gid\fP,
200 .\"O and (the least significant 9 bits of) \fIshm_perm.mode\fP.
201 °Ê²¼¤Î¥Õ¥£¡¼¥ë¥É¤ÏÊѹ¹¤Ç¤¤ë¡£
202 \fIshm_perm.uid\fP, \fIshm_perm.gid\fP,
203 \fIshm_perm.mode\fP (¤ÎºÇ²¼°Ì 9 ¥Ó¥Ã¥È)¡£
204 .\"O The effective UID of the calling process must match the owner
205 .\"O .RI ( shm_perm.uid )
207 .\"O .RI ( shm_perm.cuid )
208 .\"O of the shared memory segment, or the caller must be privileged.
209 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¼Â¸ú UID ¤¬½êͼÔ
212 .RI ( shm_perm.cuid )
213 ¤È°ìÃפ¹¤ë¤«¡¢¸Æ¤Ó½Ð¤·¸µ¤¬Æø¢¤ò»ý¤¿¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
216 .\"O Mark the segment to be destroyed.
217 .\"O The segment will only actually be destroyed
218 .\"O after the last process detaches it (i.e., when the
220 .\"O member of the associated structure
223 ¥»¥°¥á¥ó¥È¤ËÇË´þºÑ¤ß¤Î¥Þ¡¼¥¯¤òÉÕ¤±¤ë¡£
224 ¥»¥°¥á¥ó¥È¤Ï¡¢¼ÂºÝ¤Ë¤ÏºÇ¸å¥×¥í¥»¥¹¤¬¥»¥°¥á¥ó¥È¤òʬΥ¤·¤¿ (´ØÏ¢¤¹¤ë
228 ¥á¥ó¥Ð¡¼¤¬ 0 ¤Ë¤Ê¤Ã¤¿) ¸å¤Ç¤Î¤ßÇË´þ¤µ¤ì¤ë¡£
229 .\"O The caller must be the owner or creator, or be privileged.
230 ¸Æ¤Ó½Ð¤·¸µ¤Ï½êͼԤ«ºîÀ®¼Ô¤Ç¤¢¤ë¤«¡¢Æø¢¤ò»ý¤¿¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
231 .\"O If a segment has been marked for destruction, then the (nonstandard)
234 .\"O .I shm_perm.mode
235 .\"O field in the associated data structure retrieved by
238 ¥»¥°¥á¥ó¥È¤ËÇË´þ¤Î¥Þ¡¼¥¯¤¬ÉÕ¤±¤é¤ì¤ë¤È¡¢
239 ´ØÏ¢¤¹¤ë¥Ç¡¼¥¿¹½Â¤ÂΤˤª¤¤¤Æ
241 ¥Õ¥£¡¼¥ë¥É¤Î (ɸ½à¤Ç¤Ï¤Ê¤¤)
248 .\"O The caller \fImust\fP ensure that a segment is eventually destroyed;
249 .\"O otherwise its pages that were faulted in will remain in memory or swap.
250 ¸Æ¤Ó½Ð¤·¸µ¤ÏºÇ½ªÅª¤Ë¤Ï¥»¥°¥á¥ó¥È¤ò˺¤ì¤º¤ËÇË´þ\fI¤·¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤\fP¡£
251 ¤½¤¦¤Ç¤Ê¤ì¤Ð¡¢¥Õ¥©¡¼¥ë¥È (fault) ¤µ¤ì¤¿¥Ú¡¼¥¸¤Ï
252 ¥á¥â¥ê¤«¥¹¥ï¥Ã¥× (swap) ¤Ë»Ä¤ê³¤±¤ë¡£
254 .\"O .BR IPC_INFO " (Linux-specific)"
255 .BR IPC_INFO " (Linux ¸ÇÍ)"
256 .\"O Returns information about system-wide shared memory limits and
257 .\"O parameters in the structure pointed to by
259 ¥·¥¹¥Æ¥àÁ´ÂΤǤζ¦Í¥á¥â¥ê¤ÎÀ©¸Â¤È¥Ñ¥é¥á¡¼¥¿¤Ë´Ø¤¹¤ë¾ðÊó¤ò¡¢
261 ¤¬»Ø¤¹¹½Â¤ÂΤËÆþ¤ì¤ÆÊÖ¤¹¡£
262 .\"O This structure is of type
264 .\"O (thus, a cast is required),
269 .\"O feature test macro is defined:
272 ·¿¤Ç¤¢¤ë (¤½¤Î¤¿¤á¥¥ã¥¹¥È¤¬É¬ÍפǤ¢¤ë)¡£
276 µ¡Ç½¸¡ºº¥Þ¥¯¥í¤¬ÄêµÁ¤µ¤ì¤¿¾ì¹ç¤Ë
278 ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤ë:
283 .\"O unsigned long shmmax; /* Maximum segment size */
284 unsigned long shmmax; /* ºÇÂ祻¥°¥á¥ó¥È¥µ¥¤¥º */
285 .\"O unsigned long shmmin; /* Minimum segment size;
287 unsigned long shmmin; /* ºÇ¾®¥»¥°¥á¥ó¥È¥µ¥¤¥º¡£
289 .\"O unsigned long shmmni; /* Maximum number of segments */
290 unsigned long shmmni; /* ºÇÂ祻¥°¥á¥ó¥È¿ô */
291 .\"O unsigned long shmseg; /* Maximum number of segments
292 .\"O that a process can attach;
293 .\"O unused within kernel */
294 unsigned long shmseg; /* ¥×¥í¥»¥¹¤¬ÉղäǤ¤ë
296 ¥«¡¼¥Í¥ëÆâ¤Ç¤Ï̤»ÈÍÑ */
297 .\"O unsigned long shmall; /* Maximum number of pages of
298 .\"O shared memory, system-wide */
299 unsigned long shmall; /* ¶¦Í¥á¥â¥ê¤ÎºÇÂç¥Ú¡¼¥¸¿ô¡£
300 ¥·¥¹¥Æ¥àÁ´ÂΤǤÎÃÍ */
310 .\"O settings can be changed via
312 .\"O files of the same name; see
321 ¤Ë¤¢¤ëƱ¤¸Ì¾Á°¤Î¥Õ¥¡¥¤¥ë·Ðͳ¤ÇÊѹ¹²Äǽ¤Ç¤¢¤ë¡£
326 .\"O .BR SHM_INFO " (Linux-specific)"
327 .BR SHM_INFO " (Linux ¸ÇÍ)"
330 .\"O structure whose fields contain information
331 .\"O about system resources consumed by shared memory.
332 ¶¦Í¥á¥â¥ê¤¬¾ÃÈñ¤·¤Æ¤¤¤ë¥·¥¹¥Æ¥à»ñ¸»¤Ë´Ø¤¹¤ë¾ðÊó¤ò
336 .\"O This structure is defined in
340 .\"O feature test macro is defined:
343 µ¡Ç½¸¡ºº¥Þ¥¯¥í¤¬ÄêµÁ¤µ¤ì¤¿¾ì¹ç¤Ë
345 ¤Ç°Ê²¼¤Î¤è¤¦¤ËÄêµÁ¤µ¤ì¤ë:
350 .\"O int used_ids; /* # of currently existing
352 int used_ids; /* ¸½ºß¸ºß¤¹¤ë¥»¥°¥á¥ó¥È¿ô */
353 .\"O unsigned long shm_tot; /* Total number of shared
355 unsigned long shm_tot; /* ¶¦Í¥á¥â¥ê¤Î¥Ú¡¼¥¸Áí¿ô */
356 .\"O unsigned long shm_rss; /* # of resident shared
358 unsigned long shm_rss; /* ¥á¥â¥ê¾å¤Ë¤¢¤ë (¥¹¥ï¥Ã¥×¤µ¤ì¤Æ
359 ¤¤¤Ê¤¤) ¶¦Í¥á¥â¥ê¥Ú¡¼¥¸¿ô */
360 .\"O unsigned long shm_swp; /* # of swapped shared
362 unsigned long shm_swp; /* ¥¹¥ï¥Ã¥×¤µ¤ì¤Æ¤¤¤ë¶¦Í¥á¥â¥ê
364 .\"O unsigned long swap_attempts;
365 .\"O /* Unused since Linux 2.4 */
366 .\"O unsigned long swap_successes;
367 .\"O /* Unused since Linux 2.4 */
368 unsigned long swap_attempts;
369 /* Linux 2.4 °Ê¹ß¤Ç¤Ï̤»ÈÍÑ */
370 unsigned long swap_successes;
371 /* Linux 2.4 °Ê¹ß¤Ç¤Ï̤»ÈÍÑ */
376 .\"O .BR SHM_STAT " (Linux-specific)"
377 .BR SHM_STAT " (Linux ¸ÇÍ)"
380 .\"O structure as for
388 .\"O argument is not a segment identifier, but instead an index into
389 .\"O the kernel's internal array that maintains information about
390 .\"O all shared memory segments on the system.
393 °ú¤¿ô¤Ï¡¢¥»¥°¥á¥ó¥È¼±Ê̻ҤǤϤʤ¯¡¢¥·¥¹¥Æ¥à¾å¤ÎÁ´¤Æ¤Î¶¦Í¥á¥â¥ê
394 ¥»¥°¥á¥ó¥È¤Ë´Ø¤¹¤ë¾ðÊó¤ò´ÉÍý¤¹¤ë¥«¡¼¥Í¥ë¤ÎÆâÉôÇÛÎó¤Ø¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹
397 .\"O The caller can prevent or allow swapping of a shared
398 .\"O memory segment with the following \fIcmd\fP values:
399 ¸Æ¤Ó½Ð¤·¸µ¤Ï¡¢\fIcmd\fP ¤Ë°Ê²¼¤ÎÃͤò»ØÄꤹ¤ë¤³¤È¤Ç¡¢¶¦Í¥á¥â¥ê¡¦¥»¥°¥á¥ó¥È¤¬
400 ¥¹¥ï¥Ã¥×¤µ¤ì¤ë¤³¤È¤òËɻߤ·¤¿¤ê¡¢µö²Ä¤·¤¿¤ê¤Ç¤¤ë:
403 .\"O .BR SHM_LOCK " (Linux-specific)"
404 .BR SHM_LOCK " (Linux ¸ÇÍ)"
405 .\"O Prevent swapping of the shared memory segment.
406 .\"O The caller must fault in
407 .\"O any pages that are required to be present after locking is enabled.
408 ¶¦Í¥á¥â¥ê¡¦¥»¥°¥á¥ó¥È¤ò¥¹¥ï¥Ã¥×¤¹¤ë¤³¤È¤òËɻߤ¹¤ë¡£
409 ¥í¥Ã¥¯¤¬Í¸ú¤Ë¤Ê¤Ã¤¿¸å¡¢¸Æ¤Ó½Ð¤·¸µ¤Ï¡¢
410 ¸ºß¤¹¤ë¤³¤È¤¬Í׵ᤵ¤ì¤¿Á´¤Æ¤Î¥Ú¡¼¥¸¤ò¥Õ¥©¡¼¥ë¥È¤µ¤»¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤¡£
411 .\"O If a segment has been locked, then the (nonstandard)
414 .\"O .I shm_perm.mode
415 .\"O field in the associated data structure retrieved by
418 ¥»¥°¥á¥ó¥È¤¬¥í¥Ã¥¯¤µ¤ì¤ë¤È¡¢
419 ´ØÏ¢¤¹¤ë¥Ç¡¼¥¿¹½Â¤ÂΤˤª¤¤¤Æ
421 ¥Õ¥£¡¼¥ë¥É¤Î (ɸ½àŪ¤Ç¤Ï¤Ê¤¤)
428 .\"O .BR SHM_UNLOCK " (Linux-specific)"
429 .BR SHM_UNLOCK " (Linux ¸ÇÍ)"
430 .\"O Unlock the segment, allowing it to be swapped out.
431 ¥»¥°¥á¥ó¥È¤Î¥í¥Ã¥¯¤ò²ò½ü¤·¡¢¥¹¥ï¥Ã¥×¡¦¥¢¥¦¥È¤¹¤ë¤³¤È¤ò²Äǽ¤Ë¤¹¤ë¡£
433 .\"O In kernels before 2.6.10, only a privileged process
437 .\"O .BR SHM_UNLOCK .
438 2.6.10 ¤è¤êÁ°¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢Æø¢¥×¥í¥»¥¹¤À¤±¤¬
442 ¤òÍøÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤¿¡£
443 .\"O Since kernel 2.6.10, an unprivileged process can employ these operations
444 .\"O if its effective UID matches the owner or creator UID of the segment, and
447 .\"O the amount of memory to be locked falls within the
448 .\"O .B RLIMIT_MEMLOCK
449 .\"O resource limit (see
450 .\"O .BR setrlimit (2)).
451 2.6.10 °Ê¹ß¤Î¥«¡¼¥Í¥ë¤Ç¤Ï¡¢ÈóÆø¢¥×¥í¥»¥¹¤Ç¤¢¤Ã¤Æ¤â¼¡¤Î¾ò·ï¤òËþ¤¿¤»¤Ð
452 ¤³¤ì¤é¤ÎÁàºî¤òÍøÍѤ¹¤ë¤³¤È¤¬¤Ç¤¤ë¡£¤½¤Î¾ò·ï¤È¤Ï¡¢¥×¥í¥»¥¹¤Î¼Â¸ú UID
453 ¤¬¤½¤Î¥»¥°¥á¥ó¥È¤Î½êͼԤ⤷¤¯¤ÏºîÀ®¼Ô¤Î UID ¤È°ìÃפ·¡¢
455 ¤Î¾ì¹ç¤Ë¤Ï) ¥í¥Ã¥¯¤¹¤ë¥á¥â¥ê¤Î¹ç·×¤¬
459 »²¾È) ¤ÎÈÏ°ÏÆâ¤ËÆþ¤Ã¤Æ¤¤¤ë¤³¤È¤Ç¤¢¤ë¡£
460 .\" There was some weirdness in 2.6.9: SHM_LOCK and SHM_UNLOCK could
461 .\" be applied to a segment, regardless of ownership of the segment.
462 .\" This was a botch-up in the move to RLIMIT_MEMLOCK, and was fixed
463 .\" in 2.6.10. MTK, May 2005
464 .\"O .SH "RETURN VALUE"
470 .\"O operation returns the index of the highest used entry in the
471 .\"O kernel's internal array recording information about all
472 .\"O shared memory segments.
476 Áàºî¤Ï¡¢À®¸ù¤¹¤ë¤È¡¢Á´¤Æ¤Î¶¦Í¥á¥â¥ê¥»¥°¥á¥ó¥È¤Ë´Ø¤¹¤ë¾ðÊó¤ò
477 ´ÉÍý¤·¤Æ¤¤¤ë¥«¡¼¥Í¥ë¤ÎÆâÉôÇÛÎó¤Î»ÈÍÑÃ楨¥ó¥È¥ê¤Î¥¤¥ó¥Ç¥Ã¥¯¥¹¤Î
479 .\"O (This information can be used with repeated
481 .\"O operations to obtain information about all shared memory segments
483 (¤³¤Î¾ðÊó¤Ï¡¢¥·¥¹¥Æ¥à¤ÎÁ´¤Æ¤Î¶¦Í¥á¥â¥ê¥»¥°¥á¥ó¥È¤Ë´Ø¤¹¤ë¾ðÊó¤ò
486 Áàºî¤ò·«¤êÊÖ¤·¼Â¹Ô¤¹¤ëºÝ¤Ë»ÈÍѤǤ¤ë)¡£
489 .\"O operation returns the identifier of the shared memory segment
490 .\"O whose index was given in
495 ¤Ç»ØÄꤵ¤ì¤¿¥¤¥ó¥Ç¥Ã¥¯¥¹¤ò»ý¤Ä¶¦Í¥á¥â¥ê¥»¥°¥á¥ó¥È¤Î¼±Ê̻ҤòÊÖ¤¹¡£
496 .\"O Other operations return 0 on success.
497 ¾¤ÎÁàºî¤Ï¡¢À®¸ù¤Î¾ì¹ç 0 ¤òÊÖ¤¹¡£
499 .\"O On error, \-1 is returned, and
501 .\"O is set appropriately.
502 ¥¨¥é¡¼¤Î¾ì¹ç¤Ï \-1 ¤òÊÖ¤·¡¢
509 .\"O \fBIPC_STAT\fP or \fBSHM_STAT\fP is requested and
511 .\"O \fIshm_perm.mode\fP does not allow read access for
513 .\"O and the calling process does not have the
514 .\"O .B CAP_IPC_OWNER
516 \fBIPC_STAT\fP ¤Þ¤¿¤Ï \fBSHM_STAT\fP ¤¬Í׵ᤵ¤ì¡¢
517 \fIshm_perm.mode\fP ¤¬
519 ¤Ø¤ÎÆɤ߹þ¤ß¥¢¥¯¥»¥¹¤òµö¤·¤Æ¤ª¤é¤º¡¢
520 ¤«¤Ä¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤¬
522 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£ (capability) ¤ò»ý¤Ã¤Æ¤¤¤Ê¤¤¡£
531 .\"O but the address pointed to by
533 .\"O isn't accessible.
541 ¤Ç»Ø¤µ¤ì¤Æ¤¤¤ë¥¢¥É¥ì¥¹¤Ë¥¢¥¯¥»¥¹¤Ç¤¤Ê¤¤¡£
544 .\"O \fIshmid\fP points to a removed identifier.
545 \fIshmid\fP ¤¬ºï½ü (remove) ¤µ¤ì¤¿¼±ÊÌ»Ò (identifier) ¤ò»Ø¤·¤Æ¤¤¤ë¡£
548 .\"O \fIshmid\fP is not a valid identifier, or \fIcmd\fP
549 .\"O is not a valid command.
552 .\"O operation, the index value specified in
554 .\"O referred to an array slot that is currently unused.
555 \fIshmid\fP ¤¬Í¸ú¤Ê¼±Ê̻ҤǤʤ¤¤«¡¢
556 \fIcmd\fP ¤¬Í¸ú¤Ê¥³¥Þ¥ó¥É¤Ç¤Ê¤¤¡£
561 ¤Ç»ØÄꤵ¤ì¤¿¥¤¥ó¥Ç¥Ã¥¯¥¹Ãͤ¬¸½ºß̤»ÈÍѤÎÇÛÎó¤Î¥¹¥í¥Ã¥È¤ò»²¾È¤·¤Æ¤¤¤¿¡£
564 .\"O (In kernels since 2.6.9),
566 .\"O was specified and the size of the to-be-locked segment would mean
567 .\"O that the total bytes in locked shared memory segments would exceed
568 .\"O the limit for the real user ID of the calling process.
569 (2.6.9 °Ê¹ß¤Î¥«¡¼¥Í¥ë¤Ë¤ª¤¤¤Æ)
572 ¥í¥Ã¥¯¤µ¤ì¤ëͽÄê¤Î¥»¥°¥á¥ó¥È¤Î¥µ¥¤¥º
573 (¥í¥Ã¥¯¤µ¤ì¤ë¶¦Í¥á¥â¥ê¡¦¥»¥°¥á¥ó¥È¤Î¹ç·×¥Ð¥¤¥È¿ô) ¤¬¡¢
574 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¼Â¥æ¡¼¥¶¡¼ ID ¤Ë¤Ä¤¤¤Æ¤ÎÀ©¸Â¤òĶ¤¨¤¿¡£
575 .\"O This limit is defined by the
576 .\"O .B RLIMIT_MEMLOCK
577 .\"O soft resource limit (see
578 .\"O .BR setrlimit (2)).
581 ¥½¥Õ¥È»ñ¸»À©¸Â¤ÇÄêµÁ¤µ¤ì¤ë
586 .\"O \fBIPC_STAT\fP is attempted, and the GID or UID value
587 .\"O is too large to be stored in the structure pointed to by
589 \fBIPC_STAT\fP ¤¬»î¤ß¤é¤ì¡¢GID ¤ä UID ¤ÎÃͤ¬
591 ¤Ç»Ø¼¨¤µ¤ì¤ë¹½Â¤ÂΤ˳ÊǼ¤¹¤ë¤Ë¤ÏÂ礲᤮¤ë¡£
594 .\"O \fBIPC_SET\fP or \fBIPC_RMID\fP is attempted, and the
595 .\"O effective user ID of the calling process is not that of the creator
597 .\"O .IR shm_perm.cuid ),
600 .\"O .IR shm_perm.uid ),
601 .\"O and the process was not privileged (Linux: did not have the
602 .\"O .B CAP_SYS_ADMIN
604 \fBIPC_SET\fP ¤« \fBIPC_RMID\fP ¤¬»î¤ß¤é¤ì¡¢
605 ¸Æ¤Ó½Ð¤·¤¿¥×¥í¥»¥¹¤Î¼Â¸ú¥æ¡¼¥¶¡¼ ID ¤¬ºîÀ®¼Ô
606 .RI ( shm_perm.cuid )
609 ¤Ç¤â¤Ê¤¯¡¢¥×¥í¥»¥¹¤¬Æø¢¤ò»ý¤¿¤Ê¤¤ (Linux ¤Ç¤Ï
611 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤¿¤Ê¤¤)¡£
613 .\"O Or (in kernels before 2.6.9),
617 .\"O was specified, but the process was not privileged
618 .\"O (Linux: did not have the
621 ¤Þ¤¿¤Ï (2.6.9 ¤è¤êÁ°¤Î¥«¡¼¥Í¥ë¤Ç)
625 ¤¬»ØÄꤵ¤ì¤Æ¤¤¤ë¤¬¡¢¥×¥í¥»¥¹¤¬Æø¢¤ò»ý¤¿¤Ê¤¤
628 ¥±¡¼¥Ñ¥Ó¥ê¥Æ¥£¤ò»ý¤¿¤Ê¤¤)¡£
629 .\"O (Since Linux 2.6.9, this error can also occur if the
630 .\"O .B RLIMIT_MEMLOCK
631 .\"O is 0 and the caller is not privileged.)
632 (Linux 2.6.9 °Ê¹ß¤Ç¤Ï¡¢
634 ¤¬ 0 ¤Ç¸Æ¤Ó½Ð¤·¸µ¤¬Æø¢¤ò»ý¤¿¤Ê¤¤¾ì¹ç¤Ë¤â¡¢¤³¤Î¥¨¥é¡¼¤¬µ¯¤³¤ë¡£)
635 .\"O .SH "CONFORMING TO"
638 .\"O .\" SVr4 documents additional error conditions EINVAL,
639 .\"O .\" ENOENT, ENOSPC, ENOMEM, EEXIST. Neither SVr4 nor SVID documents
640 .\"O .\" an EIDRM error condition.
641 .\" SVr4 ¤Ë¤Ï¾¤Ë EINVAL, ENOENT, ENOSPC, ENOMEM,
642 .\" EEXIST ¥¨¥é¡¼¤Ë¤Ä¤¤¤Æ¤Îµ½Ò¤¬¤¢¤ë¡£
643 .\" SVr4 ¤ª¤è¤Ó SVID ¤Ë¤Ï EIDRM ¥¨¥é¡¼¤Ë¤Ä¤¤¤Æ¤Îµ½Ò¤Ï¤Ê¤¤¡£
651 .\"O operations are used by the
653 .\"O program to provide information on allocated resources.
654 .\"O In the future these may modified or moved to a /proc file system
661 ¥×¥í¥°¥é¥à¤Ç³ä¤êÅö¤ÆºÑ¤Î»ñ¸»¤Ë´Ø¤¹¤ë¾ðÊó¤òÄ󶡤¹¤ë¤¿¤á¤Ë
662 »ÈÍѤµ¤ì¤Æ¤¤¤ë¡£¾Íè¡¢¤³¤ì¤é¤ÎÁàºî¤ÏÊѹ¹¤µ¤ì¤¿¤ê¡¢
663 /proc ¥Õ¥¡¥¤¥ë¥·¥¹¥Æ¥à¤Î¥¤¥ó¥¿¥Õ¥§¡¼¥¹¤Ë°ÜÆ°¤µ¤ì¤ë¤«¤â¤·¤ì¤Ê¤¤¡£
665 .\"O Linux permits a process to attach
666 .\"O .RB ( shmat (2))
667 .\"O a shared memory segment that has already been marked for deletion
669 .\"O .IR shmctl(IPC_RMID) .
670 .\"O This feature is not available on other Unix implementations;
671 .\"O portable applications should avoid relying on it.
674 ¤ò»È¤Ã¤Æ¤¹¤Ç¤Ëºï½ü¥Þ¡¼¥¯¤¬¤Ä¤±¤é¤ì¤Æ¤¤¤ë¶¦Í¥á¥â¥ê¡¦¥»¥°¥á¥ó¥È¤ò
675 ¤¢¤ë¥×¥í¥»¥¹¤¬Éղà (attach)
677 ¤¹¤ë¤³¤È¤òµö²Ä¤·¤Æ¤¤¤ë¡£
678 ¤³¤Îµ¡Ç½¤Ï¾¤Î Unix ¤Î¼ÂÁõ¤Ç¤ÏÍøÍѤǤ¤Ê¤¤¡£
679 °Ü¿¢À¤ò¹Íθ¤·¤¿¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Ç¤Ï¤³¤ì¤Ë°Í¸¤·¤Ê¤¤¤è¤¦¤Ë¤¹¤Ù¤¤Ç¤¢¤ë¡£
681 .\"O Various fields in a \fIstruct shmid_ds\fP were typed as
686 .\"O under Linux 2.4.
687 .\"O To take advantage of this,
688 .\"O a recompilation under glibc-2.1.91 or later should suffice.
689 .\"O (The kernel distinguishes old and new calls by an
693 \fI¹½Â¤ÂÎ shmid_ds\fP Æâ¤Î¿¤¯¤Î¥Õ¥£¡¼¥ë¥É¤Ï¡¢
696 ·¿¤À¤Ã¤¿¤¬¡¢Linux 2.4 ¤Ç¤Ï
699 ¤³¤ÎÍøÅÀ¤òÀ¸¤«¤¹¤Ë¤Ï¡¢glibc-2.1.91 °Ê¹ß¤Î´Ä¶²¼¤Ç
700 ºÆ¥³¥ó¥Ñ¥¤¥ë¤¹¤ì¤Ð½½Ê¬¤Ç¤¢¤ë¡£
701 ¥«¡¼¥Í¥ë¤Ï¿·¤·¤¤·Á¼°¤Î¸Æ¤Ó½Ð¤·¤È¸Å¤¤·Á¼°¤Î¸Æ¤Ó½Ð¤·¤ò
712 .BR capabilities (7),
713 .BR shm_overview (7),