Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / lib / libcr / 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: src/lib/libc/sys/shmctl.2,v 1.9.2.4 2001/12/14 18:34:01 ru Exp $
27 .\" $DragonFly: src/lib/libcr/sys/Attic/shmctl.2,v 1.2 2003/06/17 04:26:47 dillon Exp $
28 .\"
29 .Dd July 17, 1995
30 .Dt SHMCTL 2
31 .Os
32 .Sh NAME
33 .Nm shmctl
34 .Nd shared memory control
35 .Sh LIBRARY
36 .Lb libc
37 .Sh SYNOPSIS
38 .In machine/param.h
39 .In sys/types.h
40 .In sys/ipc.h
41 .In sys/shm.h
42 .Ft int
43 .Fn shmctl "int shmid" "int cmd" "struct shmid_ds *buf"
44 .Sh DESCRIPTION
45 Performs the action specified by
46 .Fa cmd
47 on the shared memory segment identified by
48 .Fa shmid :
49 .Bl -tag -width SHM_UNLOCKX
50 .It Dv IPC_STAT
51 Fetch the segment's
52 .Fa "struct shmid_ds" ,
53 storing it in the memory pointed to by
54 .Fa buf .
55 .\"
56 .\" XXX need to make sure that this is correct for FreeBSD
57 .\"
58 .It Dv IPC_SET
59 Changes the
60 .Fa shm_perm.uid ,
61 .Fa shm_perm.gid ,
62 and
63 .Fa shm_perm.mode
64 members of the segment's
65 .Fa "struct shmid_ds"
66 to match those of the struct pointed to by
67 .Fa buf .
68 The calling process's effective uid must
69 match either
70 .Fa shm_perm.uid
71 or
72 .Fa shm_perm.cuid ,
73 or it must have superuser privileges.
74 .It Dv IPC_RMID
75 Removes the segment from the system.  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.  For the operation
79 to succeed, the calling process's effective uid must match
80 .Fa shm_perm.uid
81 or
82 .Fa shm_perm.cuid ,
83 or the process must have superuser privileges.
84 .\" .It Dv SHM_LOCK
85 .\" Locks the segment in memory.  The calling process must have
86 .\" superuser privileges. Not implemented in FreeBSD.
87 .\" .It Dv SHM_UNLOCK
88 .\" Unlocks the segment from memory.  The calling process must
89 .\" have superuser privileges.  Not implemented in FreeBSD.
90 .El
91 .Pp
92 The
93 .Fa shmid_ds
94 struct is defined as follows:
95 .\"
96 .\" I fiddled with the spaces a bit to make it fit well when viewed
97 .\" with nroff, but otherwise it's straight from sys/shm.h
98 .\"
99 .Bd -literal
100 struct shmid_ds {
101     struct ipc_perm shm_perm;   /* operation permission structure */
102     int             shm_segsz;  /* size of segment in bytes */
103     pid_t           shm_lpid;   /* process ID of last shared memory op */
104     pid_t           shm_cpid;   /* process ID of creator */
105     short           shm_nattch; /* number of current attaches */
106     time_t          shm_atime;  /* time of last shmat() */
107     time_t          shm_dtime;  /* time of last shmdt() */
108     time_t          shm_ctime;  /* time of last change by shmctl() */
109     void           *shm_internal; /* sysv stupidity */
110 };
111 .Ed
112 .Sh RETURN VALUES
113 .Rv -std shmctl
114 .Sh ERRORS
115 .Fn Shmctl
116 will fail if:
117 .Bl -tag -width Er
118 .It Bq Er EINVAL
119 Invalid operation, or
120 no shared memory segment was found corresponding to
121 .Fa shmid .
122 .\"
123 .\" XXX I think the following is right: ipcperm() only returns EPERM
124 .\"     when an attempt is made to modify (IPC_M) by a non-creator
125 .\"     non-owner
126 .It Bq Er EPERM
127 The calling process's effective uid does not match the uid of
128 the shared memory segment's owner or creator.
129 .It Bq Er EACCES
130 Permission denied due to mismatch between operation and mode of
131 shared memory segment.
132 .El
133 .Sh "SEE ALSO"
134 .Xr shmat 2 ,
135 .Xr shmdt 2 ,
136 .Xr shmget 2 ,
137 .Xr ftok 3