usched: Implement LWP lazy migration support.
[dragonfly.git] / lib / libc / sys / shmget.2
blob1d782b5abe614c150b1ce71f19c05263c8288efb
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/shmget.2,v 1.8.2.6 2001/12/14 18:34:01 ru Exp $
27 .\"
28 .Dd January 4, 2014
29 .Dt SHMGET 2
30 .Os
31 .Sh NAME
32 .Nm shmget
33 .Nd obtain a shared memory identifier
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 shmget "key_t key" "size_t size" "int flag"
43 .Sh DESCRIPTION
44 Based on the values of
45 .Fa key
46 and
47 .Fa flag ,
48 .Fn shmget
49 returns the identifier of a newly created or previously existing shared
50 memory segment.
51 .\"
52 .\" The following bit about keys and modes also applies to semaphores
53 .\" and message queues.
54 .\"
55 The key
56 is analogous to a filename: it provides a handle that names an
57 IPC object.
58 There are three ways to specify a key:
59 .Bl -bullet
60 .It
61 .Dv IPC_PRIVATE
62 may be specified, in which case a new IPC object will be created.
63 .It
64 An integer constant may be specified.
65 If no IPC object corresponding to
66 .Fa key
67 is specified and the
68 .Dv IPC_CREAT
69 bit is set in
70 .Fa flag ,
71 a new one will be created.
72 .It
73 .Fn ftok
74 may be used to generate a key from a pathname.
75 See
76 .Xr ftok 3 .
77 .El
78 .Pp
79 The mode of a newly created IPC object is determined by
80 .Em OR Ns 'ing
81 the following constants into the
82 .Fa flag
83 parameter:
84 .Bl -tag -width XSHM_WXX6XXX
85 .It Dv SHM_R
86 Read access for user.
87 .It Dv SHM_W
88 Write access for user.
89 .It Dv ( SHM_R>>3 )
90 Read access for group.
91 .It Dv ( SHM_W>>3 )
92 Write access for group.
93 .It Dv ( SHM_R>>6 )
94 Read access for other.
95 .It Dv ( SHM_W>>6 )
96 Write access for other.
97 .El
98 .\"
99 .\" XXX - we should also mention how uid, euid, and gid affect ownership
100 .\"       and use
102 .\" end section about keys and modes
105 When creating a new shared memory segment,
106 .Fa size
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).
110 .Sh RETURN VALUES
111 Upon successful completion,
112 .Fn shmget
113 returns the positive integer identifier of a shared memory segment.
114 Otherwise, -1 is returned and
115 .Va errno
116 set to indicate the error.
117 .Sh ENVIRONMENT
118 The XSI Interprocess Communication family of functions is also available
119 as an implementation in userspace.
120 To use it, the
121 .Xr sysvipcd 8
122 daemon has to be running.
124 If the
125 .Ev USR_SYSVIPC
126 variable is set in a process' environment, the process and its children
127 will use the userspace implementation.
128 .Sh ERRORS
129 .Fn Shmget
130 will fail if:
131 .Bl -tag -width Er
133 .\" XXX What about ipcperm failing?
135 .It Bq Er EINVAL
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.
139 .It Bq Er ENOENT
140 No shared memory segment was found matching
141 .Fa key ,
143 .Dv IPC_CREAT
144 was not specified.
145 .It Bq Er ENOSPC
146 The kernel was unable to allocate enough memory to
147 satisfy the request.
148 .It Bq Er EEXIST
149 .Dv IPC_CREAT
151 .Dv IPC_EXCL
152 were specified, and a shared memory segment corresponding to
153 .Fa key
154 already exists.
156 .Sh "SEE ALSO"
157 .Xr shmat 2 ,
158 .Xr shmctl 2 ,
159 .Xr shmdt 2 ,
160 .Xr ftok 3
161 .Sh AUTHORS
162 .An -nosplit
165 specific userspace implementation (see
166 .Sx ENVIRONMENT )
167 was written by
168 .An Larisa Grigore .