File: semctl.2

package info (click to toggle)
manpages-ja 0.5.0.0.20080615-1
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 20,508 kB
  • ctags: 1
  • sloc: sh: 13,690; perl: 157; makefile: 114
file content (525 lines) | stat: -rw-r--r-- 12,945 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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
.\" 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 Tue Oct 22 17:53:56 1996 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified Fri Jun 19 10:59:15 1998 by Andries Brouwer <aeb@cwi.nl>
.\" Modified Sun Feb 18 01:59:29 2001 by Andries Brouwer <aeb@cwi.nl>
.\" Modified 20 Dec 2001, Michael Kerrisk <mtk.manpages@gmail.com>
.\" Modified 21 Dec 2001, aeb
.\" Modified 27 May 2004, Michael Kerrisk <mtk.manpages@gmail.com>
.\"     Added notes on CAP_IPC_OWNER requirement
.\" Modified 17 Jun 2004, Michael Kerrisk <mtk.manpages@gmail.com>
.\"     Added notes on CAP_SYS_ADMIN requirement for IPC_SET and IPC_RMID
.\" Modified, 11 Nov 2004, Michael Kerrisk <mtk.manpages@gmail.com>
.\"	Language and formatting clean-ups
.\"	Rewrote semun text
.\"	Added semid_ds and ipc_perm structure definitions
.\" 2005-08-02, mtk: Added IPC_INFO, SEM_INFO, SEM_STAT descriptions.
.\"
.\" Japanese Version Copyright (c) 1997,1998 HANATAKA Shinya
.\"         all rights reserved.
.\" Translated 1997-02-23, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Modified 1998-09-10, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\" Updated & Modified 2001-06-03, Yuichi SATO <ysato@h4.dion.ne.jp>
.\" Updated & Modified 2002-01-02, Yuichi SATO
.\" Updated & Modified 2005-01-03, Yuichi SATO <ysato444@yahoo.co.jp>
.\" Updated & Modified 2005-10-10, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
.\"
.\"WORD:	semaphore		ޥե
.\"WORD:	semaphore set		ޥե
.\"WORD:	union			
.\"WORD:	buffer			Хåե
.\"WORD:	member			С
.\"WORD:	superuser		ѡ桼
.\"WORD:	effective uid		¸桼 ID
.\"WORD:	creator			
.\"WORD:	owner			ͭ
.\"WORD:	entry			ȥ
.\"WORD:	undo			ɥ
.\"WORD:	implement		
.\"WORD:	feature test macro	ǽޥ
.\"
.TH SEMCTL 2 2004-11-10 "Linux" "Linux Programmer's Manual"
.SH ̾
semctl \- ޥեԤʤ
.SH 
.nf
.B #include <sys/types.h>
.B #include <sys/ipc.h>
.B #include <sys/sem.h>
.sp
.BI "int semctl(int " semid ", int " semnum ", int " cmd ", ...);"
.fi
.SH 
.BR semctl ()
ϡ
.I semid
ǻꤵ줿ޥե (semaphore set)
ޤϥޥե
.I semnun
ܤΥޥեФơ
.I cmd
ǻꤵ줿Ԥʤ
(Υޥեֹ 0 Ϥޤ)
.PP
δؿϡ
.I cmd
ͤ˰¸ơ3 Ĥޤ 4 Ĥΰġ
 4 Ĥξ硢 4 η
.I "union semun"
Ǥ롣
\fIƤӽФץ\fPϡ
ζ (union) ʲΤ褦ʤФʤʤ

.nf
.in +4n
union semun {
    int              val;    /* SETVAL  */
    struct semid_ds *buf;    /* IPC_STAT, IPC_SET ѤΥХåե */
    unsigned short  *array;  /* GETALL, SETALL Ѥ */
    struct seminfo  *__buf;  /* IPC_INFO ѤΥХåե
                                (Linux ͭ) */
};
.in
.fi
.PP
.I semid_ds
ǡ¤Τ \fI<sys/sem.h>\fP ǰʲΤ褦Ƥ:
.nf
.in +4n

struct semid_ds {
    struct ipc_perm sem_perm;  /* ͭȵ */
    time_t          sem_otime; /* Ǹ semop λ */
    time_t          sem_ctime; /* ǸѹԤ줿 */
    unsigned short  sem_nsems; /* Υޥեο */
};
.fi
.PP
.in
.fi
.PP
.I ipc_perm
¤Τ \fI<sys/ipc.h>\fP ǰʲΤ褦Ƥ
(Ĵ줿եɤ
.B IPC_SET
ȤäǽǤ):
.PP
.nf
.in +4n
struct ipc_perm {
    key_t key;            /* semget(2) Ϳ륭 */
    uid_t \fBuid\fP;            /* ͭ (owner) μ¸ UID */
    gid_t \fBgid\fP;            /* ͭԤμ¸ GID */
    uid_t cuid;           /*  (creator) μ¸ UID */
    gid_t cgid;           /* Ԥμ¸ GID */
    unsigned short \fBmode\fP;  /*  */
    unsigned short seq;   /* ֹ */
};
.in
.fi
.PP
.I cmd
Ȥͭͤ
.TP 12
.B IPC_STAT
.I semid
˴ϢŤ줿ͥǡ¤Τξ
.I arg.buf
ǻؤ줿
.I semid_ds
¤Τإԡ롣
.I semnum
̵뤵롣
ƤӽФץϤΥޥեФ
ɤ߹ߵĤʤФʤʤ
.TP
.B IPC_SET
.I arg.buf
ǻꤵ줿
.I semid_ds
¤ΤΥСΤĤͤ
Υޥե˴ϢŤ줿ͥǡ¤Τ˽񤭹ߡ
.I sem_ctime
Сͤ⹹롣
¤ΤΰʲΥС:
.IR sem_perm.uid ,
.IR sem_perm.gid ,
.I sem_perm.mode
(κDz 9 ӥå)
ƤӽФץμ¸ UID ͭ
.RI ( sem_perm.uid )
ޤϺ
.RI ( sem_perm.cuid )
Ȱפ뤫ƤӽФͤøʤФʤʤ
.I semnum
̵뤵롣
.TP
.B IPC_RMID
ޥե򤿤˺ν
.BR semop (2)
ǥ֥åƤƤΥץܳФᤵ
(顼֤ͤơ
.I errno

.B EIDRM
ꤵ)
ƤӽФץμ¸桼 ID 
ΥޥեκԤޤϽͭԤȰפ뤫
ƤӽФͤøʤФʤʤ
.I semnum
̵뤵롣
.TP
.BR IPC_INFO " (Linux ͭ)"
ƥΤǤΥޥե¤ȥѥ᡼˴ؤ
.I arg.__buf
ؤ¤Τ֤
ι¤Τ
.I seminfo
Ǥ롣
.I seminfo

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

struct  seminfo {
    int semmap;  /* ޥեޥåפκ票ȥ;
                    ̤ */
    int semmni;  /* ޥեκ */
    int semmns;  /* ޥեΥޥե
                     */
    int semmnu;  /* ɥ¤ΤΥƥΤǤ
                    ; ̤ */
    int semmsl;  /* ĤΥޥեκ祻ޥե */
    int semopm;  /* semop(2) Ϥκ */
    int semume;  /* ץΥɥȥ
                    κ; ̤ */
    int semusz;  /* ¤ sem_undo Υ */
    int semvmx;  /* ޥեκ */
    int semaem;  /* ޥեĴ (semaphore adjustment;
                     SEM_UNDO) Τ˵Ͽ */
};

.in
.fi

.IR semmsl ,
.IR semmns ,
.IR semopm ,
.I semmni

.I /proc/sys/kernel/sem
ͳѹǽǤ롣
ܤ
.BR proc (5)
򻲾ȡ
.TP
.BR SEM_INFO " (Linux ͭ)"
.B IPC_INFO
ΤȤƱǼ
.I seminfo
¤Τ֤
âʲΥեɤˤϥޥե񤷤Ƥ륷ƥ񸻤
ؤ󤬳Ǽۤʤ롣
.I semusz
եɤϸߥƥ¸ߤ륻ޥեο֤
.I semaem
եɤϥƥƤΥޥե˴ޤޤ
ޥե֤
.TP
.BR SEM_STAT " (Linux ͭ)"
.B IPC_STAT
Ʊ
.I semid_ds
¤Τ֤
â
.I semid
ϡޥե̻ҤǤϤʤƥƤΥޥե
˴ؤ륫ͥؤΥǥåǤ롣
.TP
.B GETALL
ƤΥޥե
.B semval
 (ߤ) 
.I arg.array
֤
.I semnum
̵뤵롣
ƤӽФץϤΥޥեɤ߹ߵĤʤФʤʤ
.TP
.B GETNCNT
ƥॳϽ
.I semnum
ܤΥޥե
.B semncnt
 (ΥޥեͤäΤԤäƤץ) ֤
(
.I semnum
ܤΥޥե
.B semval
äԤäƤץο֤)
ƤӽФץϤΥޥեɤ߹ߵĤʤФʤʤ
.TP
.B GETPID
ƥॳϽ
.I semnum
ܤΥޥե
.B sempid
 (
.I semnum
ܤΥޥե˺Ǹ
.BR semop (2)
¹Ԥץ PID) ֤
ƤӽФץϤΥޥեɤ߹ߵĤʤФʤʤ
.TP
.B GETVAL
ƥॳϽ
.I semnum
ܤΥޥե
.B semval
֤ͤ
ƤӽФץϤΥޥեɤ߹ߵĤʤФʤʤ
.TP
.B GETZCNT
ƥॳϽ
.I semnum
ܤΥޥե
.B semzcnt
 (Υޥեͤ 0 ˤʤΤԤäƤץο) ֤
(
.I semnum
ܤΥޥե
.B semval
ͤ 0 ˤʤΤԤäƤץο֤)
ƤӽФץϤΥޥեɤ߹ߵĤʤФʤʤ
.TP
.B SETALL
ƤΥޥե
.B semval

.I arg.array
ǻꤵ줿ͤꤹ롣
ν˴Ϣ
.I semid_ds
¤Τ
.I sem_ctime
Сͤ⹹롣
ƤΥץΥޥեѹˤĤƤΥɥȥ
.RB ( semop (2)
򻲾) Ͼõ (clear) 롣
ޥեͤѹˤꡢ¾Υץǥ֥åƤ
.BR semop (2)
³ԤĤȡΥץϵ (wake up)
.I semnum
̵뤵롣
ƤӽФץϤΥޥե
ѹ (񤭹) ĤʤФʤʤ
.TP
.B SETVAL

.I semnum
ܤΥޥե
.B semval

.I arg.val
ͤꤹ롣ν˴Ϣ
.I semid_ds
¤Τ
.I sem_ctime
Сͤ⹹롣
ƤΥץΥޥեѹˤĤƤΥɥȥϾõ롣
ޥեͤѹˤꡢ¾Υץǥ֥åƤ
.BR semop (2)
³ԤĤȡΥץϵ (wake up)
ƤӽФץϤΥޥե
ѹ (񤭹) ĤʤФʤʤ
.SH ֤
Ԥ硢
.BR semctl ()
 \-1 ֤
.I errno
ˤΥ顼򼨤

ǤʤХƥॳ
.I cmd
ˤäưʲǤʤ֤ͤ:
.TP 11
.B GETNCNT
.B semncnt

.TP
.B GETPID
.B sempid

.TP
.B GETVAL
.B semval

.TP
.B GETZCNT
.B semzcnt

.TP
.B IPC_INFO
ƤΥޥե˴ؤƤ륫ͥλ
ȥΥǥåκ
(ξϡƥƤΥޥե˴ؤ뤿
.B SEM_STAT
򷫤֤¹Ԥݤ˻ѤǤ)
.TP
.B SEM_INFO
.B IPC_INFO
Ʊ
.TP
.B SEM_STAT
.I semid
ǻꤵ줿ǥåĥޥեμ̻
.LP
.I cmd
ͤʳξ硢 0 ֤롣
.SH 顼
Ԥ
.I errno
ˤϰʲͤΤɤ줫ꤵ:
.TP 11
.B EACCES
.I cmd

.BR GETALL ,
.BR GETPID ,
.BR GETVAL ,
.BR GETNCNT ,
.BR GETZCNT ,
.BR IPC_STAT ,
.BR SEM_STAT ,
.BR SETALL ,
.B SETVAL
Τβ줫ͤ
ƤӽФץޥեФɬפȤĤ
.B CAP_IPC_OWNER
ѥӥƥ (capability) äƤʤ
.TP
.B EFAULT
.I arg.buf
ޤ
.I arg.array
ǻؤƤ륢ɥ쥹˥뤳ȤǤʤ
.TP
.B EIDRM
ޥե礬줿
.TP
.B EINVAL
.I cmd
ޤ
.I semid
̵ͤꤵ줿
⤷ϡ
.B SEM_STAT
ξˡ
.I semid
ǻꤵ줿ǥå̤ͤѤΥåȤ򻲾ȤƤ
.TP
.B EPERM
.I cmd

.B IPC_SET
ޤ
.B IPC_RMID
ꤵ졢ƤӽФץμ¸桼 ID ޥե
.RI ( sem_perm.cuid
ǸĤ) Ԥޤ
.RI ( sem_perm.uid
ǸĤ) ͭԤǤʤ
ץ
.B CAP_SYS_ADMIN
ѥӥƥʤ
.TP
.B ERANGE
.I cmd

.B SETALL
ޤ
.B SETVAL
ꤵ졢(ΥޥեΤɤ줫)
.B semval
ꤵͤ 0 꾮
.B SEMVMX
.SH 
SVr4, POSIX.1-2001.
.\" SVr4 ˤϡ¾ EINVAL, EOVERFLOW 顼ˤĤƤεҤ롣
.SH 
.BR IPC_INFO ,
.BR SEM_STAT ,
.B SEM_INFO

.BR ipcs (8)
ץˤäƳ줿񸻤ˤĤƾ󶡤뤿˻Ѥ롣
ŪˤϤѹ뤫
/proc ե롦ƥࡦ󥿥ե˰ư뤫⤷ʤ
.LP
\fI¤ semid_ds\fP ¿Υեɤϡ
Linux 2.2 Ǥ
.I short
äLinux 2.4 Ǥ
.I long
ˤʤä
ˤϡglibc-2.1.91 ʹߤδĶ
ƥѥ뤹нʬǤ롣
ͥϿθƤӽФȸŤθƤӽФ
.I cmd

.B IPC_64
ե饰Ƕ̤롣
.PP
ΥС glibc Ǥϡ
.I semun
Τ \fI<sys/sem.h>\fP Ƥ
POSIX.1-2001 ǤϸƤӽФ¦ζΤɬפ롣
ζΤ\fIʤ\fP glibc ΥСǤϡ
ޥ
.B _SEM_SEMUN_UNDEFINED
 \fI<sys/sem.h>\fP Ƥ롣
.PP
ʲ
.BR semctl ()
˱ƶ륻ޥեΥƥ:
.TP 11
.B SEMVMX
.B semval
κ : ¸ (32767)
.LP
ܿ뤿ΰɤˡϡ 4 Ĥΰ
.BR semctl ()
ƤӽФȤǤ롣
.SH Ϣ
.BR ipc (2),
.BR semget (2),
.BR semop (2),
.BR capabilities (7),
.BR sem_overview (7),
.BR svipc (7)