2 .\" Copyright (c) 1995 David Hovemeyer <daveho@infocom.com>
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
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.
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.
26 .\" $FreeBSD: src/lib/libc/sys/shmget.2,v 1.8.2.6 2001/12/14 18:34:01 ru Exp $
33 .Nd obtain a shared memory identifier
42 .Fn shmget "key_t key" "size_t size" "int flag"
44 Based on the values of
49 returns the identifier of a newly created or previously existing shared
52 .\" The following bit about keys and modes also applies to semaphores
53 .\" and message queues.
56 is analogous to a filename: it provides a handle that names an
58 There are three ways to specify a key:
62 may be specified, in which case a new IPC object will be created.
64 An integer constant may be specified.
65 If no IPC object corresponding to
71 a new one will be created.
74 may be used to generate a key from a pathname.
79 The mode of a newly created IPC object is determined by
81 the following constants into the
84 .Bl -tag -width XSHM_WXX6XXX
88 Write access for user.
90 Read access for group.
92 Write access for group.
94 Read access for other.
96 Write access for other.
99 .\" XXX - we should also mention how uid, euid, and gid affect ownership
102 .\" end section about keys and modes
105 When creating a new shared memory segment,
107 indicates the desired size of the new segment in bytes.
108 The size of the segment may be rounded up to a multiple convenient to the
109 kernel (i.e., the page size).
111 Upon successful completion,
113 returns the positive integer identifier of a shared memory segment.
114 Otherwise, -1 is returned and
116 set to indicate the error.
118 The XSI Interprocess Communication family of functions is also available
119 as an implementation in userspace.
122 daemon has to be running.
126 variable is set in a process' environment, the process and its children
127 will use the userspace implementation.
133 .\" XXX What about ipcperm failing?
136 Size specified is greater than the size of the previously existing segment.
137 Size specified is less than the system imposed minimum, or greater than
138 the system imposed maximum.
140 No shared memory segment was found matching
146 The kernel was unable to allocate enough memory to
152 were specified, and a shared memory segment corresponding to
165 specific userspace implementation (see