]> CyberLeo.Net >> Repos - FreeBSD/releng/8.1.git/blob - lib/libc/sys/shmat.2
Copy stable/8 to releng/8.1 in preparation for 8.1-RC1.
[FreeBSD/releng/8.1.git] / lib / libc / sys / shmat.2
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$
27 .\"
28 .Dd August 2, 1995
29 .Dt SHMAT 2
30 .Os
31 .Sh NAME
32 .Nm shmat ,
33 .Nm shmdt
34 .Nd attach or detach shared memory
35 .Sh LIBRARY
36 .Lb libc
37 .Sh SYNOPSIS
38 .In machine/param.h
39 .In sys/types.h
40 .In sys/ipc.h
41 .In sys/shm.h
42 .Ft void *
43 .Fn shmat "int shmid" "const void *addr" "int flag"
44 .Ft int
45 .Fn shmdt "const void *addr"
46 .Sh DESCRIPTION
47 The
48 .Fn shmat
49 system call
50 attaches the shared memory segment identified by
51 .Fa shmid
52 to the calling process's address space.
53 The address where the segment
54 is attached is determined as follows:
55 .\"
56 .\" These are cribbed almost exactly from Stevens, _Advanced Programming in
57 .\" the UNIX Environment_.
58 .\"
59 .Bl -bullet
60 .It
61 If
62 .Fa addr
63 is 0, the segment is attached at an address selected by the
64 kernel.
65 .It
66 If
67 .Fa addr
68 is nonzero and SHM_RND is not specified in
69 .Fa flag ,
70 the segment is attached the specified address.
71 .It
72 If
73 .Fa addr
74 is specified and SHM_RND is specified,
75 .Fa addr
76 is rounded down to the nearest multiple of SHMLBA.
77 .El
78 .Pp
79 The
80 .Fn shmdt
81 system call
82 detaches the shared memory segment at the address specified by
83 .Fa addr
84 from the calling process's address space.
85 .Sh RETURN VALUES
86 Upon success,
87 .Fn shmat
88 returns the address where the segment is attached; otherwise, -1
89 is returned and
90 .Va errno
91 is set to indicate the error.
92 .Pp
93 .Rv -std shmdt
94 .Sh ERRORS
95 The
96 .Fn shmat
97 system call
98 will fail if:
99 .Bl -tag -width Er
100 .It Bq Er EINVAL
101 No shared memory segment was found corresponding to
102 .Fa shmid .
103 .It Bq Er EINVAL
104 The
105 .Fa addr
106 argument
107 was not an acceptable address.
108 .El
109 .Pp
110 The
111 .Fn shmdt
112 system call
113 will fail if:
114 .Bl -tag -width Er
115 .It Bq Er EINVAL
116 The
117 .Fa addr
118 argument
119 does not point to a shared memory segment.
120 .El
121 .Sh "SEE ALSO"
122 .Xr shmctl 2 ,
123 .Xr shmget 2