]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - lib/libc/sys/shmctl.2
libc: Fix most issues reported by mandoc
[FreeBSD/FreeBSD.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 October 10, 2015
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 sys/types.h
38 .In sys/ipc.h
39 .In sys/shm.h
40 .Ft int
41 .Fn shmctl "int shmid" "int cmd" "struct shmid_ds *buf"
42 .Sh DESCRIPTION
43 Performs the action specified by
44 .Fa cmd
45 on the shared memory segment identified by
46 .Fa shmid :
47 .Bl -tag -width SHM_UNLOCKX
48 .It Dv IPC_STAT
49 Fetch the segment's
50 .Fa "struct shmid_ds" ,
51 storing it in the memory pointed to by
52 .Fa buf .
53 .\"
54 .\" XXX need to make sure that this is correct for FreeBSD
55 .\"
56 .It Dv IPC_SET
57 Changes the
58 .Fa shm_perm.uid ,
59 .Fa shm_perm.gid ,
60 and
61 .Fa shm_perm.mode
62 members of the segment's
63 .Fa "struct shmid_ds"
64 to match those of the struct pointed to by
65 .Fa buf .
66 The calling process's effective uid must
67 match either
68 .Fa shm_perm.uid
69 or
70 .Fa shm_perm.cuid ,
71 or it must have superuser privileges.
72 .It Dv IPC_RMID
73 Removes the segment from the system.
74 The removal will not take
75 effect until all processes having attached the segment have exited.
76 For the operation
77 to succeed, the calling process's effective uid must match
78 .Fa shm_perm.uid
79 or
80 .Fa shm_perm.cuid ,
81 or the process must have superuser privileges.
82 If the
83 .Va kern.ipc.shm_allow_removed
84 .Xr sysctl 3
85 variable is set to 0, once the IPC_RMID operation has taken place,
86 no further processes will be allowed to attach the segment.
87 .\" .It Dv SHM_LOCK
88 .\" Locks the segment in memory.  The calling process must have
89 .\" superuser privileges. Not implemented in FreeBSD.
90 .\" .It Dv SHM_UNLOCK
91 .\" Unlocks the segment from memory.  The calling process must
92 .\" have superuser privileges.  Not implemented in FreeBSD.
93 .El
94 .Pp
95 The
96 .Vt shmid_ds
97 structure is defined as follows:
98 .\"
99 .\" I fiddled with the spaces a bit to make it fit well when viewed
100 .\" with nroff, but otherwise it is straight from sys/shm.h
101 .\"
102 .Bd -literal
103 struct shmid_ds {
104     struct ipc_perm shm_perm;   /* operation permission structure */
105     size_t          shm_segsz;  /* size of segment in bytes */
106     pid_t           shm_lpid;   /* process ID of last shared memory op */
107     pid_t           shm_cpid;   /* process ID of creator */
108     int             shm_nattch; /* number of current attaches */
109     time_t          shm_atime;  /* time of last shmat() */
110     time_t          shm_dtime;  /* time of last shmdt() */
111     time_t          shm_ctime;  /* time of last change by shmctl() */
112 };
113 .Ed
114 .Sh RETURN VALUES
115 .Rv -std shmctl
116 .Sh ERRORS
117 The
118 .Fn shmctl
119 system call
120 will fail if:
121 .Bl -tag -width Er
122 .It Bq Er EINVAL
123 Invalid operation, or
124 no shared memory segment was found corresponding to
125 .Fa shmid .
126 .\"
127 .\" XXX I think the following is right: ipcperm() only returns EPERM
128 .\"     when an attempt is made to modify (IPC_M) by a non-creator
129 .\"     non-owner
130 .It Bq Er EPERM
131 The calling process's effective uid does not match the uid of
132 the shared memory segment's owner or creator.
133 .It Bq Er EACCES
134 Permission denied due to mismatch between operation and mode of
135 shared memory segment.
136 .El
137 .Sh "SEE ALSO"
138 .Xr shmat 2 ,
139 .Xr shmdt 2 ,
140 .Xr shmget 2 ,
141 .Xr ftok 3