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