]>
Commit | Line | Data |
---|---|---|
9bccf70c A |
1 | .\" $OpenBSD: shmget.2,v 1.2 1996/10/08 01:20:16 michaels Exp $ |
2 | .\" $NetBSD: shmget.2,v 1.1 1995/10/16 23:49:32 jtc Exp $ | |
3 | .\" | |
4 | .\" Copyright (c) 1995 Frank van der Linden | |
5 | .\" All rights reserved. | |
6 | .\" | |
7 | .\" Redistribution and use in source and binary forms, with or without | |
8 | .\" modification, are permitted provided that the following conditions | |
9 | .\" are met: | |
10 | .\" 1. Redistributions of source code must retain the above copyright | |
11 | .\" notice, this list of conditions and the following disclaimer. | |
12 | .\" 2. Redistributions in binary form must reproduce the above copyright | |
13 | .\" notice, this list of conditions and the following disclaimer in the | |
14 | .\" documentation and/or other materials provided with the distribution. | |
15 | .\" 3. All advertising materials mentioning features or use of this software | |
16 | .\" must display the following acknowledgement: | |
17 | .\" This product includes software developed for the NetBSD Project | |
18 | .\" by Frank van der Linden | |
19 | .\" 4. The name of the author may not be used to endorse or promote products | |
20 | .\" derived from this software without specific prior written permission | |
21 | .\" | |
22 | .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR | |
23 | .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |
24 | .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. | |
25 | .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, | |
26 | .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT | |
27 | .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | |
28 | .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | |
29 | .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | |
30 | .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF | |
31 | .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
32 | .\"/ | |
33 | .Dd August 17, 1995 | |
34 | .Dt SHMGET 2 | |
35 | .Os | |
36 | .Sh NAME | |
37 | .Nm shmget | |
38 | .Nd get shared memory area identifier | |
39 | .Sh SYNOPSIS | |
40 | .Fd #include <sys/types.h> | |
41 | .Fd #include <sys/ipc.h> | |
42 | .Fd #include <sys/shm.h> | |
43 | .Ft int | |
44 | .Fn shmget "key_t key" "int size" "int shmflg" | |
45 | .Sh DESCRIPTION | |
46 | .Fn shmget | |
47 | returns the shared memory identifier associated with the key | |
48 | .Fa key . | |
91447636 | 49 | .Pp |
9bccf70c A |
50 | A shared memory segment is created if either |
51 | .Fa key | |
52 | is equal to IPC_PRIVATE, or | |
53 | .Fa key | |
54 | does not have a shared memory segment identifier associated with it, and the IPC_CREAT | |
55 | bit is set in | |
56 | .Fa shmflg. | |
91447636 | 57 | .Pp |
9bccf70c A |
58 | If a new shared memory segment is created, the data structure associated with it (the |
59 | .Va shmid_ds | |
60 | structure, see | |
61 | .Xr shmctl 2 ) | |
62 | is initialized as follows: | |
63 | .Bl -bullet | |
64 | .It | |
65 | .Va shm_perm.cuid | |
66 | and | |
67 | .Va shm_perm.uid | |
68 | are set to the effective uid of the calling process. | |
69 | .It | |
70 | .Va shm_perm.gid | |
71 | and | |
72 | .Va shm_perm.cgid | |
73 | are set to the effective gid of the calling process. | |
74 | .It | |
75 | .Va shm_perm.mode | |
76 | is set to the lower 9 bits of | |
77 | .Fa shmflg . | |
78 | .It | |
79 | .Va shm_lpid , | |
80 | .Va shm_nattch , | |
81 | .Va shm_atime , | |
82 | and | |
83 | .Va shm_dtime | |
84 | are set to 0 | |
85 | .It | |
86 | .Va shm_ctime | |
87 | is set to the current time. | |
88 | .It | |
89 | .Va shm_segsz | |
90 | is set to the value of | |
91 | .Fa size . | |
92 | .El | |
93 | .Sh RETURN VALUES | |
94 | Upon successful completion a positive shared memory segment identifier is returned. | |
95 | Otherwise, -1 is returned and the global variable | |
96 | .Va errno | |
97 | is set to indicate the error. | |
98 | .Sh ERRORS | |
99 | .Bl -tag -width Er | |
100 | .It Bq Er EACESS | |
101 | A shared memory segment is already associated with | |
102 | .Fa key | |
103 | and the caller has no permission to access it. | |
104 | .It Bq Er EEXIST | |
105 | Both IPC_CREAT and IPC_EXCL are set in | |
106 | .Fa shmflg , | |
107 | and a shared memory segment is already associated with | |
108 | .Fa key . | |
109 | .It Bq Er ENOSPC | |
110 | A new shared memory indentifier could not be created because the system limit | |
111 | for the number of shared memory identifiers has been reached. | |
112 | .It Bq Er ENOENT | |
113 | IPC_CREAT was not set in | |
114 | .Fa shmflg | |
115 | and no shared memory segment associated with | |
116 | .Fa key | |
117 | was found. | |
118 | .It Bq Er ENOMEM | |
119 | There is not enough memory left to created a shared memory segment of the | |
120 | requested size. | |
121 | .El | |
122 | .Sh SEE ALSO | |
123 | .Xr shmctl 2 , | |
124 | .Xr shmat 2 , | |
125 | .Xr shmdt 2 |