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
|
.\" Copyright (c) 1993 Luigi P. Bai (lpb@softint.com) July 28, 1993
.\"
.\" 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 Wed Jul 28 11:03:24 1993, Rik Faith <faith@cs.unc.edu>
.\" Modified Sun Nov 28 16:43:30 1993, Rik Faith <faith@cs.unc.edu>
.\" with material from Giorgio Ciucci <giorgio@crcc.it>
.\" Portions Copyright 1993 Giorgio Ciucci <giorgio@crcc.it>
.\" Modified Fri Jan 31 17:24:31 1997 by Eric S. Raymond <esr@thyrsus.com>
.\"
.\" Japanese Version Copyright (c) 1997 HANATAKA Shinya
.\" all rights reserved.
.\" Translated Sat Mar 1 16:49:09 JST 1997
.\" by HANATAKA Shinya <hanataka@abyss.rim.or.jp>
.\"
.\"WORD: shared memory ͭ
.\"WORD: segment
.\"WORD: owner ͭ
.\"WORD: group 롼
.\"WORD: creator
.\"WORD: super-user ѡ桼
.\"WORD: detach ʬΥ
.\"WORD: attach ղ
.\"WORD: swap å
.\"WORD: identifier ̻
.\"WORD: member С
.\"
.TH SHMCTL 2 "November 28, 1993" "Linux 0.99.11" "Linux Programmer's Manual"
.SH ̾
shmctl \- ͭ(shared memory)椹
.SH
.ad l
.B #include <sys/ipc.h>
.sp
.B #include <sys/shm.h>
.sp
.BI "int shmctl(int " shmid ", int " cmd ", struct shmid_ds *" buf );
.ad b
.SH
\fBshmctl()\fP
ϥ桼ͭꡦȤξꡢ
ͭνͭ(owner)롼(group)ӵ(permission)
ꤹ뤳\fIshmid\fPǻꤵ줿ȤˤĤƤξ
\fIshmid_ds\fP ¤Τ֤:
.PP
.in +0.5i
.nf
struct shmid_ds {
struct ipc_perm shm_perm; /* operation perms */
int shm_segsz; /* size of segment (bytes) */
time_t shm_atime; /* last attach time */
time_t shm_dtime; /* last detach time */
time_t shm_ctime; /* last change time */
unsigned short shm_cpid; /* pid of creator */
unsigned short shm_lpid; /* pid of last operator */
short shm_nattch; /* no. of current attaches */
/* the following are private */
unsigned short shm_npages; /* size of segment (pages) */
unsigned long *shm_pages;
struct shm_desc *attaches; /* descriptors for attaches */
};
.fi
.in -0.5i
.PP
\fIshm_perm\fP СƤ:
.PP
.in +0.5i
.nf
struct ipc_perm
{
key_t key;
\fBushort uid\fP; /* \fBowner\fP euid and egid */
\fBushort gid\fP;
ushort cuid; /* creator euid and egid */
ushort cgid;
\fBushort mode\fP; /* lower 9 bits of access modes */
ushort seq; /* sequence number */
};
.fi
.PP
ʲ \fIcmds\fP ѤǤ:
.br
.TP 12
.B IPC_STAT
϶ͭꡦȤ \fIbuf\fP Хåե˥ԡ뤿
Ѥ롣桼϶ͭꡦȤФ\fBɤ߹\fP
ǤʤФʤʤ
.TP
.B IPC_SET
ϥ桼 \fIshm_perms\fP \fIuid\fP\fIgid\fP\fImode\fP ѹ
뤿˻Ѥ롣\fImode\fPϲ 9ӥåȤΤߤѤ롣
.I shm_ctime
롣桼Ͻͭ(owner)(creator)
ѡ桼(super-user)ǤʤФʤʤ
.TP
.B IPC_RMID
ϥȤ˲(destroy)ޡդΤ˻Ѥ롣ºݤˤ
ǸʬΥ(detach)Ԥʤ줿(Ϣ
.I shmid_ds
¤Τ
.I shm_nattch
Сˤʤä)˲롣桼ϽͭԤԤ
ѡ桼ǤʤФʤʤ
.PP
桼ϺǽŪˤϥȤ˺줺˲ʤФʤʤ
ǤʤС˲ʤäڡϥå(swap)˻Ĥ³롣
.PP
äơʲ \fIcmds\fP ǡ\fBѡ桼\fP
ͭꡦȤåפ뤳Ȥ˸ꡢǤǤ:
(Linux Τ)
.br
.TP 12
.B SHM_LOCK
϶ͭꡦȤåפ뤳Ȥ˸롣
桼ϥåǽˤʤä˥åᤷڡ
¸ߤ뤳ȤǧʤФʤʤ
.TP
.B SHM_UNLOCK
϶ͭꡦȤåסȤ뤳Ȥǽˤ롣
.PP
.BR IPC_INFO
.BR SHM_STAT
.B SHM_INFO
楳
.BR ipcs (8)
ץˤäƳƤ줿ˤĤƤξ뤿
Ѥ롣ŪˤϤ proc ե롦ƥࡦե
ѤΤ˽뤫⤷ʤ
.PP
.SH ƥࡦ
.TP
.B fork()
.B fork()
θˡҥץղ(attach)줿ͭꡦȤѾ롣
.TP
.B exec()
.B exec()
θˡ
Ƥղä줿ͭꡦȤʬΥ(detach)롣
(˲Ϥʤ)
.TP
.B exit()
.B exit()
ˤơ
Ƥղä줿ͭꡦȤʬΥ롣(˲Ϥʤ)
.PP
.SH ֤
0 ֤顼ξ \-1 ֤
.SH 顼
顼ξ
.B errno
ʲΤɤ줫ꤵ:
.TP 12
.B EACCES
\fBIPC_STAT\fP ᤵ졢\fIshm_perm.modes\fP
.IR shmid
ؤɤ߹ߥƤʤä֤롣
.TP
.B EFAULT
.I cmd
.B IPC_SET
.B IPC_STAT
ꤵ줿
.I buf
ǻؤƤ륢ɥ쥹˥Ǥʤ
.TP
.B EINVAL
\fIshmid\fP ͭʼ̻(identifier)Ǥʤ\fIcmd\fP
ͭʥޥɤǤʤ֤롣
.TP
.B EIDRM
\fIshmid\fP (remove)줿̻ҤؤƤ
֤롣
.TP
.B EPERM
\fBIPC_SET\fP \fBIPC_RMID\fP ߤ졢桼
ͭԤǤԤǤ⥹ѡ桼Ǥʤ桼
롼פ¾ԤȤƵĤƤʤ֤롣
.SH
SVr4, SVID. SVr4 ˤ¾ EINVAL, ENOENT, ENOSPC, ENOMEM,
EEXIST 顼ˤĤƤεҤ롣SVr4 SVID ˤ
EIDRM 顼ˤĤƤεҤϤʤ
.SH Ϣ
.BR shmget (2),
.BR shmop (2)
|