aboutsummaryrefslogtreecommitdiff
path: root/ja_JP.eucJP/man/man2/shmat.2
blob: f0737fabd190dcd0653d5ed8c1def288e952bae9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
.\"
.\" Copyright (c) 1995 David Hovemeyer <daveho@infocom.com>
.\"
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" %FreeBSD: src/lib/libc/sys/shmat.2,v 1.8.2.5 2001/08/31 10:15:15 ru Exp %
.\"
.\" $FreeBSD: doc/ja_JP.eucJP/man/man2/shmat.2,v 1.6 2001/09/02 00:05:25 horikawa Exp $
.Dd August 2, 1995
.Dt SHMAT 2
.Os
.Sh 名称
.Nm shmat ,
.Nm shmdt
.Nd 共有メモリをアタッチまたはデタッチする
.Sh ライブラリ
.Lb libc
.Sh 書式
.Fd #include <machine/param.h>
.Fd #include <sys/types.h>
.Fd #include <sys/ipc.h>
.Fd #include <sys/shm.h>
.Ft void *
.Fn shmat "int shmid" "void *addr" "int flag"
.Ft int
.Fn shmdt "void *addr"
.Sh 解説
.Fn shmat
は、
.Fa shmid
によって識別された共有メモリセグメントを呼び出しプロセスの
アドレス空間にアタッチします。セグメントがアタッチされる
アドレスは次のように決定されます。
.\"
.\" These are cribbed almost exactly from Stevens, _Advanced Programming in
.\" the UNIX Environment_.
.\"
.Bl -bullet
.It
.Fa addr
が 0 の場合、セグメントは、カーネルが選択したアドレスにアタッチされます。
.It
.Fa addr
が 0 でなく、しかも SHM_RND が
.Fa flag
で指定されない場合、セグメントは指定のアドレスにアタッチされます。
.It
.Fa addr
が指定されており、しかも SHM_RND が指定されている場合、
.Fa addr
は最も近い SHMLBA の倍数に切捨てされます。
.El
.Pp
.Fn shmdt
は、
.Fa addr
で指定されるアドレスにある共有メモリセグメントを、呼び出しプロセスの
アドレス空間からデタッチします。
.Sh 戻り値
正常に完了すると、
.Fn shmat
はセグメントがアタッチされているアドレスを返します。そうでない場合は -1
が返され、エラーを示すために
.Va errno
が設定されます。
.Pp
.Rv -std shmdt
.Sh エラー
.Fn shmat
は次の場合に処理を失敗します。
.Bl -tag -width Er
.It Bq Er EINVAL
.Fa shmid
に対応する共有メモリセグメントが見つかりませんでした。
.It Bq Er EINVAL
.Fa addr
が有効なアドレスではありませんでした。
.El
.Pp
.Fn shmdt
は次の場合に処理に失敗します。
.Bl -tag -width Er
.It Bq Er EINVAL
.Fa addr
は共有メモリセグメントを指していません。
.El
.Sh 関連項目
.Xr shmctl 2 ,
.Xr shmget 2