File: shmctl.2

package info (click to toggle)
manpages-ja 0.5.0.0.20100315-1
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 21,156 kB
  • ctags: 1
  • sloc: sh: 13,935; perl: 157; makefile: 114
file content (433 lines) | stat: -rw-r--r-- 12,509 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
.\" Copyright (c) 1993 Luigi P. Bai (lpb@softint.com) July 28, 1993
.\" and Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
.\" and Copyright 2004, 2005 Michael Kerrisk <mtk.manpages@gmail.com>
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\"
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.\" Modified 1993-07-28, Rik Faith <faith@cs.unc.edu>
.\" Modified 1993-11-28, Giorgio Ciucci <giorgio@crcc.it>
.\" Modified 1997-01-31, Eric S. Raymond <esr@thyrsus.com>
.\" Modified 2001-02-18, Andries Brouwer <aeb@cwi.nl>
.\" Modified 2002-01-05, 2004-05-27, 2004-06-17,
.\"    Michael Kerrisk <mtk.manpages@gmail.com>
.\" Modified 2004-10-11, aeb
.\" Modified, Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
.\"	Language and formatting clean-ups
.\"	Updated shmid_ds structure definitions
.\"	Added information on SHM_DEST and SHM_LOCKED flags
.\"	Noted that CAP_IPC_LOCK is not required for SHM_UNLOCK
.\"		since kernel 2.6.9
.\" Modified, 2004-11-25, mtk, notes on 2.6.9 RLIMIT_MEMLOCK changes
.\" 2005-04-25, mtk -- noted aberrant Linux behavior w.r.t. new
.\"	attaches to a segment that has already been marked for deletion.
.\" 2005-08-02, mtk: Added IPC_INFO, SHM_INFO, SHM_STAT descriptions.
.\"
.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
.\"         all rights reserved.
.\" Translated 1997-03-01, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated & Modified 2001-06-13, Yuichi SATO <ysato@h4.dion.ne.jp>
.\" Updated & Modified 2005-01-05, Yuichi SATO <ysato444@yahoo.co.jp>
.\" Updated & Modified 2005-09-06, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\" Updated & Modified 2005-10-08, Akihiro MOTOKI
.\" Updated 2006-07-21, Akihiro MOTOKI, LDP v2.36
.\"
.\"WORD:	shared memory		ͭ
.\"WORD:	segment			
.\"WORD:	owner			ͭ
.\"WORD:	group			롼
.\"WORD:	creator			
.\"WORD:	super-user		ѡ桼
.\"WORD:	detach			ʬΥ
.\"WORD:	attach			ղ
.\"WORD:	swap			å
.\"WORD:	identifier		̻
.\"WORD:	member			С
.\"WORD:	feature test macro	ǽޥ
.\"
.TH SHMCTL 2 2008-08-07 "Linux" "Linux Programmer's Manual"
.SH ̾
shmctl \- ͭ (shared memory) 椹
.SH 
.ad l
.B #include <sys/ipc.h>
.br
.B #include <sys/shm.h>
.sp
.BI "int shmctl(int " shmid ", int " cmd ", struct shmid_ds *" buf );
.ad b
.SH 
.BR shmctl ()
ϡ̻Ҥ
.I shmid
ζͭꡦȤФ
.I cmd
ǻؼ̿¹Ԥ롣
.PP
.I buf
ϡ \fIshmid_ds\fP ¤ΤؤΥݥ󥿤Ǥ롣
ι¤Τ \fI<sys/shm.h>\fP ǰʲΤ褦Ƥ
.PP
.in +4n
.nf
struct shmid_ds {
    struct ipc_perm shm_perm;    /* ͭȵ */
    size_t          shm_segsz;   /* ȤΥ (Х) */
    time_t          shm_atime;   /* Ǹղ (attach) λ */
    time_t          shm_dtime;   /* ǸʬΥ (detach) λ */
    time_t          shm_ctime;   /* ǸѹԤ줿 */
    pid_t           shm_cpid;    /*  (creator)  PID */
    pid_t           shm_lpid;    /* Ǹ shmat(2)/shmdt(2)  PID */
    shmatt_t        shm_nattch;  /* ղäƤ */
    ...
};
.fi
.in
.PP
.I ipc_perm
¤Τ \fI<sys/ipc.h>\fP ǰʲΤ褦Ƥ
(Ĵ줿եɤ
.B IPC_SET
ȤäǽǤ):
.PP
.in +4n
.nf
struct ipc_perm {
    key_t          __key;    /* shmget(2) Ϳ륭 */
    uid_t          \fBuid\fP;      /* ͭԤμ¸ UID */
    gid_t          \fBgid\fP;      /* ͭԤμ¸ GID */
    uid_t          cuid;     /* Ԥμ¸ UID */
    gid_t          cgid;     /* Ԥμ¸ GID */
    unsigned short \fBmode\fP;     /* \fB\fP + SHM_DEST 
                                SHM_LOCKED ե饰 */
    unsigned short __seq;    /* ֹ */
};
.fi
.in
.PP
.I cmd
Ȥͭͤϰʲ̤:
.br
.TP 10
.B IPC_STAT
.I shmid
˴ϢŤ줿ͥǡ¤Τξ
\fIbuf\fP ǻؤ줿
.I shmid_ds
¤Τ˥ԡ롣
ƤӽФ϶ͭꡦȤФ
ɤ߹ߵĤʤФʤʤ
.TP
.B IPC_SET
.I buf
ˤäƻؤ
.I shmid_ds
¤ΤΤĤΥСͤ
ζͭꡦȤ˴ϢŤ줿ͥǡ¤Τ˽񤭹ߡ
.I shm_ctime
С⹹롣
ʲΥեɤѹǤ롣
\fIshm_perm.uid\fP, \fIshm_perm.gid\fP,
\fIshm_perm.mode\fP (κDz 9 ӥå)
ƤӽФץμ¸ UID ͭ
.RI ( shm_perm.uid )
ޤϺ
.RI ( shm_perm.cuid )
Ȱפ뤫ƤӽФøʤФʤʤ
.TP
.B IPC_RMID
Ȥ˴ѤߤΥޡդ롣
ȤϡºݤˤϺǸץȤʬΥ (Ϣ
.I shmid_ds
¤Τ
.I shm_nattch
С 0 ˤʤä) ǤΤ˴롣
ƤӽФϽͭԤԤǤ뤫øʤФʤʤ
Ȥ˴Υޡդȡ
Ϣǡ¤Τˤ
.I shm_perm.mode
եɤ (ɸǤϤʤ)
.B SHM_DEST
ե饰ꤵ롣
Υǡ¤Τ
.B IPC_STAT
Ǽ롣
.PP
ƤӽФϺǽŪˤϥȤ˺줺˴\fIʤФʤʤ\fP
ǤʤСե (fault) 줿ڡ
꤫å (swap) ˻Ĥ³롣
.TP 10
.BR IPC_INFO " (Linux ͭ)"
ƥΤǤζͭ¤ȥѥ᡼˴ؤ
.I buf
ؤ¤Τ֤
ι¤Τ
.I shminfo
Ǥ (Τᥭ㥹ȤɬפǤ)
.I shminfo

.B _GNU_SOURCE
ǽޥ줿
.I <sys/shm.h>
ǰʲΤ褦:
.nf
.in +4n

struct  shminfo {
    unsigned long shmmax; /* 祻ȥ */
    unsigned long shmmin; /* Ǿȥ
                              1 */
    unsigned long shmmni; /* 祻ȿ */
    unsigned long shmseg; /* ץղäǤ
                             Ȥκ
                             ͥǤ̤ */
    unsigned long shmall; /* ͭκڡ
                             ƥΤǤ */
};

.in
.fi

.IR shmmni ,
.IR shmmax ,
.I shmall

.I /proc
ˤƱ̾ΥեͳѹǽǤ롣
ܤ
.BR proc (5)
򻲾ȡ
.TP
.BR SHM_INFO " (Linux ͭ)"
꤬ͭ񤷤Ƥ륷ƥ񸻤˴ؤ
Ǽ
.I shm_info
¤Τ֤
ι¤Τϡ
.B _GNU_SOURCE
ǽޥ줿
.I <sys/shm.h>
ǰʲΤ褦:
.nf
.in +4n

struct shm_info {
    int           used_ids; /* ¸ߤ륻ȿ */
    unsigned long shm_tot;  /* ͭΥڡ */
    unsigned long shm_rss;  /* ˤ (åפ
                               ʤ) ͭڡ */
    unsigned long shm_swp;  /* åפƤ붦ͭ
                               ڡ */
    unsigned long swap_attempts;
                            /* Linux 2.4 ʹߤǤ̤ */
    unsigned long swap_successes;
                            /* Linux 2.4 ʹߤǤ̤ */
};
.in
.fi
.TP
.BR SHM_STAT " (Linux ͭ)"
.B IPC_STAT
Ʊ
.I shmid_ds
¤Τ֤
â
.I shmid
ϡȼ̻ҤǤϤʤƥƤζͭ
Ȥ˴ؤ륫ͥؤΥǥå
Ǥ롣
.PP
ƤӽФϡ\fIcmd\fP ˰ʲͤꤹ뤳ȤǡͭꡦȤ
åפ뤳ȤɻߤꡢĤǤ:
.br
.TP 10
.BR SHM_LOCK " (Linux ͭ)"
ͭꡦȤ򥹥åפ뤳Ȥɻߤ롣
åͭˤʤä塢ƤӽФϡ
¸ߤ뤳Ȥ׵ᤵ줿ƤΥڡեȤʤФʤʤ
Ȥåȡ
Ϣǡ¤Τˤ
.I shm_perm.mode
եɤ (ɸŪǤϤʤ)
.B SHM_LOCKED
ե饰ꤵ롣
Υǡ¤Τ
.B IPC_STAT
Ǽ롣
.TP
.BR SHM_UNLOCK " (Linux ͭ)"
ȤΥååסȤ뤳Ȥǽˤ롣
.PP
2.6.10 ΥͥǤϡøץ
.B SHM_LOCK

.B SHM_UNLOCK
Ѥ뤳ȤǤ
2.6.10 ʹߤΥͥǤϡøץǤäƤ⼡ξ
Ѥ뤳ȤǤ롣ξȤϡץμ¸ UID
ΥȤνͭԤ⤷ϺԤ UID Ȱפ
.RB ( SHM_LOCK
ξˤ) åιפ
.B RLIMIT_MEMLOCK
.RB ( setrlimit (2)
) ϰäƤ뤳ȤǤ롣
.\" There was some weirdness in 2.6.9: SHM_LOCK and SHM_UNLOCK could
.\" be applied to a segment, regardless of ownership of the segment.
.\" This was a botch-up in the move to RLIMIT_MEMLOCK, and was fixed
.\" in 2.6.10.  MTK, May 2005
.SH ֤
.B IPC_INFO

.B SHM_INFO
ϡȡƤζͭꥻȤ˴ؤ
Ƥ륫ͥλ楨ȥΥǥå
֤ͤ
(ξϡƥƤζͭꥻȤ˴ؤ
뤿ˡ
.B SHM_STAT
򷫤֤¹Ԥݤ˻ѤǤ)
.B SHM_STAT
ϡȡ
.I shmid
ǻꤵ줿ǥåĶͭꥻȤμ̻Ҥ֤
¾ϡξ 0 ֤

顼ξ \-1 ֤
.I errno
Ŭڤꤹ롣
.SH 顼
.TP
.B EACCES

\fBIPC_STAT\fP ޤ \fBSHM_STAT\fP ׵ᤵ졢
\fIshm_perm.mode\fP 
.I shmid
ؤɤ߹ߥƤ餺
ĸƤӽФץ
.B CAP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)
ץdzƺѤλ񸻤˴ؤ󶡤뤿
ѤƤ롣衢ѹ줿ꡢ
/proc ե륷ƥΥ󥿥ե˰ư뤫⤷ʤ

Linux Ǥϡ
.I shmctl(IPC_RMID)
ȤäƤǤ˺ޡĤƤ붦ͭꡦȤ
ץղ (attach)
.RB ( shmat (2))
뤳ȤĤƤ롣
εǽ¾ Unix μǤѤǤʤ
ܿθץꥱǤϤ˰¸ʤ褦ˤ٤Ǥ롣

\fI¤ shmid_ds\fP ¿Υեɤϡ
Linux 2.2 Ǥ
.I short
äLinux 2.4 Ǥ
.I long
ˤʤä
ˤϡglibc-2.1.91 ʹߤδĶ
ƥѥ뤹нʬǤ롣
ͥϿθƤӽФȸŤθƤӽФ
.I cmd

.B IPC_64
ե饰Ƕ̤롣
.SH Ϣ
.BR mlock (2),
.BR setrlimit (2),
.BR shmget (2),
.BR shmop (2),
.BR capabilities (7),
.BR shm_overview (7),
.BR svipc (7)