|
|
1.1 root 1: .TH SHMOP 2
2: .SH NAME
3: shmop \- shared memory operations
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: .B char \(**shmat (shmid, shmaddr, shmflg)
13: .B int shmid;
14: .B char \(**shmaddr
15: .B int shmflg;
16: .PP
17: .B int shmdt (shmaddr)
18: .B char \(**shmaddr
19: .fi
20: .SH DESCRIPTION
21: .I Shmat
22: attaches the shared memory segment associated with the shared memory identifier
23: specified by
24: .I shmid
25: to the data segment of the calling process.
26: The segment is attached at the address specified by one of the following
27: criteria:
28: .IP
29: If
30: .I shmaddr
31: is equal to zero, the segment is attached at the first available address as
32: selected by the system.
33: .IP
34: If
35: .I shmaddr
36: is not equal to zero and
37: .RI ( shmflg " &"
38: .SM
39: .B SHM_RND\*S)
40: is ``true'', the segment is attached at the address given by
41: .RI ( shmaddr " -"
42: .RI ( shmaddr " modulus"
43: .SM
44: .BR SHMLBA\*S "))."
45: .IP
46: If
47: .I shmaddr
48: is not equal to zero and
49: .RI ( shmflg " &"
50: .SM
51: .B SHM_RND\*S)
52: is ``false'', the segment is attached at the address given by
53: .IR shmaddr .
54: .PP
55: The segment is attached for reading if
56: .RI ( shmflg " &"
57: .SM
58: .B SHM_RDONLY\*S)
59: is ``true''
60: .SM
61: \%{READ}\*S,
62: otherwise it is attached for reading and writing
63: .SM
64: \%{READ/WRITE}\*S.
65: .PP
66: .I Shmat
1.1.1.2 ! root 67: fails and not attach the shared memory segment if one or more of the
! 68: following is true:
1.1 root 69: .TP 15
70: .SM
71: \%[EINVAL]
72: .I Shmid
73: is not a valid shared memory identifier.
74: .TP
75: .SM
76: \% [EACCES]
77: Operation permission is denied to the calling process (see
78: .IR intro (2)).
79: .TP
80: .SM
81: \%[ENOMEM]
82: The available data space
83: is not large enough to accommodate the shared memory segment.
84: .TP
85: .SM
86: \%[EINVAL]
87: .I Shmaddr
88: is not equal to zero, and the value of
89: .RI ( shmaddr " -"
90: .RI ( shmaddr " modulus"
91: .SM
92: .BR SHMLBA\*S "))"
93: is an illegal address.
94: .TP
95: .SM
96: \%[EINVAL]
97: .I Shmaddr
98: is not equal to zero,
99: .RI ( shmflg " &"
100: .SM
101: .B SHM_RND\*S)
102: is ``false'', and the value of
103: .I shmaddr
104: is an illegal address.
105: .TP
106: .SM
107: \%[EMFILE]
108: The number of shared memory segments attached to the calling process would
109: exceed the system-imposed limit.
110: .PP
111: .TP 15
112: .SM
113: \%[EINVAL]
114: .I Shmdt
115: detaches from the calling process's data segment
116: the shared memory segment located at the address specified by
117: .IR shmaddr.
118: .PP
119: .TP 15
120: .SM
121: \%[EINVAL]
122: .I Shmdt
1.1.1.2 ! root 123: fails and not detach the shared memory segment if
1.1 root 124: .I shmaddr
125: is not the data segment start address of a shared memory segment.
126: .SH RETURN VALUES
127: Upon successful completion, the return value is as follows:
128: .br
129: .ne 8v
130: .IP
131: .I Shmat
132: returns the data segment start address of the attached shared memory segment.
133: .IP
134: .I Shmdt
135: returns a value of 0.
136: .PP
137: Otherwise, a value of \-1 is returned and
138: .I errno
139: is set to indicate the error.
140: .SH SEE ALSO
141: exec(2), exit(2), fork(2), intro(2), shmctl(2), shmget(2).
142: .\" @(#)shmop.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.