|
|
1.1 root 1: .TH SHMGET 2
2: .SH NAME
3: shmget \- get shared memory segment
4: .SH SYNOPSIS
5: .B #include <sys/types.h>
6: .br
7: .B #include <sys/ipc.h>
8: .br
9: .B #include <sys/shm.h>
10: .PP
11: .nf
12: .BR "int shmget (key, size, shmflg)
13: .B key_t key;
14: .B int size, shmflg;
15: .fi
16: .SH DESCRIPTION
17: .I Shmget
18: returns the shared memory identifier associated with
19: .IR key .
20: .PP
21: A shared memory identifier and associated data structure and shared memory
22: segment of size
23: .I size
24: bytes (see
25: .IR intro (2))
1.1.1.2 ! root 26: is created for
1.1 root 27: .I key
28: if one of the following are true:
29: .IP
30: .I Key
31: is equal to
32: .SM
33: .BR IPC_PRIVATE .
34: .IP
35: .I Key
36: does not already have a shared memory identifier associated with it, and
37: .RI ( shmflg " & "
38: .SM
39: .BR IPC_CREAT\*S )
40: is ``true''.
41: .PP
42: Upon creation, the data structure associated with the new shared memory
43: identifier is initialized as follows:
44: .IP
45: .BR Shm_perm.cuid ", " shm_perm.uid ,
46: .BR shm_perm.cgid ", and " shm_perm.gid
47: are set equal to the effective user
48: .SM ID
49: and effective group
50: .SM ID\*S,
51: respectively, of the calling process.
52: .IP
53: The low-order 9 bits of
54: .B shm_perm.mode
55: are set equal to the low-order 9 bits of
56: .IR shmflg .
57: .B Shm_segsz
58: is set equal to the value of
59: .IR size .
60: .IP
61: .BR Shm_lpid ", " shm_nattch ",
62: .BR shm_atime ", and " shm_dtime "
63: are set equal to 0.
64: .IP
65: .B Shm_ctime
66: is set equal to the current time.
67: .PP
68: .I Shmget
1.1.1.2 ! root 69: fails if one or more of the following are true:
1.1 root 70: .TP 15
71: .SM
72: .SM
73: \%[EINVAL]
74: .I Size
75: is less than the system-imposed minimum
76: or greater than the system-imposed maximum.
77: .TP
78: .SM
79: \%[EACCES]
80: A shared memory identifier exists for
81: .I key
82: but operation permission (see
83: .IR intro (2))
84: as specified by the low-order 9 bits of
85: .I shmflg
86: would not be granted.
87: .TP
88: .SM
89: \%[EINVAL]
90: A shared memory identifier exists for
91: .I key
92: but the size of the segment associated with it is less than
93: .I size
94: and
95: .I size
96: is not equal to zero.
97: .TP
98: .SM
99: \%[ENOENT]
100: A shared memory identifier does not exist for
101: .I key
102: and
103: .RI ( shmflg " &"
104: .SM
105: .BR IPC_CREAT\*S )
106: is ``false''.
107: .TP
108: .SM
109: \%[ENOSPC]
110: A shared memory identifier is to be created but
111: the system-imposed limit on the maximum number of
112: allowed shared memory identifiers system wide
113: would be exceeded.
114: .TP
115: .SM
116: \%[ENOMEM]
117: A shared memory identifier and associated shared memory segment are to be
118: created but the amount of available physical memory is not sufficient to
119: fill the request.
120: .TP
121: .SM
122: \%[EEXIST]
123: A shared memory identifier exists for
124: .I key
125: but
126: .RI "((" shmflg " & "
127: .SM
128: .BR IPC_CREAT\*S ") and ("
129: .IR shmflg " & "
130: .SM
131: .BR IPC_EXCL\*S "))"
132: is ``true''.
133: .br
134: .ne 7v
135: .SH "RETURN VALUE"
136: Upon successful completion,
137: a non-negative integer,
138: namely a shared memory identifier is returned.
139: Otherwise, a value of \-1 is returned and
140: .I errno\^
141: is set to indicate the error.
142: .SH SEE ALSO
143: intro(2), shmctl(2), shmop(2).
144: .\" @(#)shmget.2 6.2 of 9/6/83
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.