]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - lib/libc/sys/shmctl.2
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / lib / libc / sys / shmctl.2
1 .\"
2 .\" Copyright (c) 1995 David Hovemeyer <daveho@infocom.com>
3 .\"
4 .\" All rights reserved.
5 .\"
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
8 .\" are met:
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\"    notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\"    notice, this list of conditions and the following disclaimer in the
13 .\"    documentation and/or other materials provided with the distribution.
14 .\"
15 .\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 .\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD$
27 .\"
28 .Dd July 17, 1995
29 .Dt SHMCTL 2
30 .Os
31 .Sh NAME
32 .Nm shmctl
33 .Nd shared memory control
34 .Sh LIBRARY
35 .Lb libc
36 .Sh SYNOPSIS
37 .In machine/param.h
38 .In sys/types.h
39 .In sys/ipc.h
40 .In sys/shm.h
41 .Ft int
42 .Fn shmctl "int shmid" "int cmd" "struct shmid_ds *buf"
43 .Sh DESCRIPTION
44 Performs the action specified by
45 .Fa cmd
46 on the shared memory segment identified by
47 .Fa shmid :
48 .Bl -tag -width SHM_UNLOCKX
49 .It Dv IPC_STAT
50 Fetch the segment's
51 .Fa "struct shmid_ds" ,
52 storing it in the memory pointed to by
53 .Fa buf .
54 .\"
55 .\" XXX need to make sure that this is correct for FreeBSD
56 .\"
57 .It Dv IPC_SET
58 Changes the
59 .Fa shm_perm.uid ,
60 .Fa shm_perm.gid ,
61 and
62 .Fa shm_perm.mode
63 members of the segment's
64 .Fa "struct shmid_ds"
65 to match those of the struct pointed to by
66 .Fa buf .
67 The calling process's effective uid must
68 match either
69 .Fa shm_perm.uid
70 or
71 .Fa shm_perm.cuid ,
72 or it must have superuser privileges.
73 .It Dv IPC_RMID
74 Removes the segment from the system.
75 The removal will not take
76 effect until all processes having attached the segment have exited;
77 however, once the IPC_RMID operation has taken place, no further
78 processes will be allowed to attach the segment.
79 For the operation
80 to succeed, the calling process's effective uid must match
81 .Fa shm_perm.uid
82 or
83 .Fa shm_perm.cuid ,
84 or the process must have superuser privileges.
85 .\" .It Dv SHM_LOCK
86 .\" Locks the segment in memory.  The calling process must have
87 .\" superuser privileges. Not implemented in FreeBSD.
88 .\" .It Dv SHM_UNLOCK
89 .\" Unlocks the segment from memory.  The calling process must
90 .\" have superuser privileges.  Not implemented in FreeBSD.
91 .El
92 .Pp
93 The
94 .Vt shmid_ds
95 structure is defined as follows:
96 .\"
97 .\" I fiddled with the spaces a bit to make it fit well when viewed
98 .\" with nroff, but otherwise it is straight from sys/shm.h
99 .\"
100 .Bd -literal
101 struct shmid_ds {
102     struct ipc_perm shm_perm;   /* operation permission structure */
103     int             shm_segsz;  /* size of segment in bytes */
104     pid_t           shm_lpid;   /* process ID of last shared memory op */
105     pid_t           shm_cpid;   /* process ID of creator */
106     short           shm_nattch; /* number of current attaches */
107     time_t          shm_atime;  /* time of last shmat() */
108     time_t          shm_dtime;  /* time of last shmdt() */
109     time_t          shm_ctime;  /* time of last change by shmctl() */
110     void           *shm_internal; /* sysv stupidity */
111 };
112 .Ed
113 .Sh RETURN VALUES
114 .Rv -std shmctl
115 .Sh ERRORS
116 The
117 .Fn shmctl
118 system call
119 will fail if:
120 .Bl -tag -width Er
121 .It Bq Er EINVAL
122 Invalid operation, or
123 no shared memory segment was found corresponding to
124 .Fa shmid .
125 .\"
126 .\" XXX I think the following is right: ipcperm() only returns EPERM
127 .\"     when an attempt is made to modify (IPC_M) by a non-creator
128 .\"     non-owner
129 .It Bq Er EPERM
130 The calling process's effective uid does not match the uid of
131 the shared memory segment's owner or creator.
132 .It Bq Er EACCES
133 Permission denied due to mismatch between operation and mode of
134 shared memory segment.
135 .El
136 .Sh "BUGS"
137 The segment size has size_t type.
138 The shm_segsz member of the
139 .Vt shmid_ds
140 structure has type int, which is too short to represent the full range
141 of values for a segment size.
142 If shared memory limits are raised to allow segments with size > 2 GB
143 to be created, be aware that IPC_STAT call may return a truncated value
144 for shm_segsz.
145 .El
146 .Sh "SEE ALSO"
147 .Xr shmat 2 ,
148 .Xr shmdt 2 ,
149 .Xr shmget 2 ,
150 .Xr ftok 3