link.2: Use .Fn and add .Nm linkat
[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 October 29, 2011
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.  The address where the segment
51 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 SHM_RND is not specified in
66 .Fa flag ,
67 the segment is attached the specified address.
68 .It
69 If
70 .Fa addr
71 is specified and SHM_RND is specified,
72 .Fa addr
73 is rounded down to the nearest multiple of SHMLBA.
74 .El
75 .Pp
76 .Fn Shmdt
77 detaches the shared memory segment at the address specified by
78 .Fa addr
79 from the calling process's address space.
80 .Sh RETURN VALUES
81 Upon success,
82 .Fn shmat
83 returns the address where the segment is attached; otherwise, -1
84 is returned and
85 .Va errno
86 is set to indicate the error.
87 .Pp
88 .Rv -std shmdt
89 .Sh ERRORS
90 .Fn Shmat
91 will fail if:
92 .Bl -tag -width Er
93 .It Bq Er EINVAL
94 No shared memory segment was found corresponding to
95 .Fa shmid .
96 .It Bq Er EINVAL
97 .Fa addr
98 was not an acceptable address.
99 .El
100 .Pp
101 .Fn Shmdt
102 will fail if:
103 .Bl -tag -width Er
104 .It Bq Er EINVAL
105 .Fa addr
106 does not point to a shared memory segment.
107 .El
108 .Sh "SEE ALSO"
109 .Xr shmctl 2 ,
110 .Xr shmget 2