wait.2: Fix excessive .Dv usage. Use proper markup.
[dragonfly.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: src/lib/libc/sys/shmat.2,v 1.8.2.6 2001/12/14 18:34:01 ru Exp $
27 .\"
28 .Dd January 4, 2014
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 .Fn Shmat
48 attaches the shared memory segment identified by
49 .Fa shmid
50 to the calling process's address space.
51 The address where the segment is attached is determined as follows:
52 .\"
53 .\" These are cribbed almost exactly from Stevens, _Advanced Programming in
54 .\" the UNIX Environment_.
55 .\"
56 .Bl -bullet
57 .It
58 If
59 .Fa addr
60 is 0, the segment is attached at an address selected by the
61 kernel.
62 .It
63 If
64 .Fa addr
65 is nonzero and
66 .Dv SHM_RND
67 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
74 .Dv SHM_RND
75 is specified,
76 .Fa addr
77 is rounded down to the nearest multiple of
78 .Dv SHMLBA .
79 .El
80 .Pp
81 .Fn Shmdt
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 ENVIRONMENT
95 The XSI Interprocess Communication family of functions is also available
96 as an implementation in userspace.
97 To use it, the
98 .Xr sysvipcd 8
99 daemon has to be running.
100 .Pp
101 If the
102 .Ev USR_SYSVIPC
103 variable is set in a process' environment, the process and its children
104 will use the userspace implementation.
105 .Sh ERRORS
106 .Fn Shmat
107 will fail if:
108 .Bl -tag -width Er
109 .It Bq Er EINVAL
110 No shared memory segment was found corresponding to
111 .Fa shmid .
112 .It Bq Er EINVAL
113 .Fa addr
114 was not an acceptable address.
115 .El
116 .Pp
117 .Fn Shmdt
118 will fail if:
119 .Bl -tag -width Er
120 .It Bq Er EINVAL
121 .Fa addr
122 does not point to a shared memory segment.
123 .El
124 .Sh "SEE ALSO"
125 .Xr shmctl 2 ,
126 .Xr shmget 2
127 .Sh AUTHORS
128 .An -nosplit
129 The
130 .Dx
131 specific userspace implementation (see
132 .Sx ENVIRONMENT )
133 was written by
134 .An Larisa Grigore .