I'm very pleased to announce the release of our new website and documentation using the new toolchain with Hugo and AsciiDoctor. To get more information about the new toolchain please read the FreeBSD Documentation Project Primer[1], Hugo docs[2] and AsciiDoctor docs[3]. Acknowledgment: Benedict Reuschling <bcr@> Glen Barber <gjb@> Hiroki Sato <hrs@> Li-Wen Hsu <lwhsu@> Sean Chittenden <seanc@> The FreeBSD Foundation [1] https://docs.FreeBSD.org/en/books/fdp-primer/ [2] https://gohugo.io/documentation/ [3] https://docs.asciidoctor.org/home/ Approved by: doceng, core
109 lines
3.1 KiB
Groff
109 lines
3.1 KiB
Groff
.\"
|
|
.\" 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.18 2004/07/02 23:52:13 ru Exp %
|
|
.\"
|
|
.\" $FreeBSD$
|
|
.Dd August 2, 1995
|
|
.Dt SHMAT 2
|
|
.Os
|
|
.Sh 名称
|
|
.Nm shmat ,
|
|
.Nm shmdt
|
|
.Nd 共有メモリをアタッチまたはデタッチする
|
|
.Sh ライブラリ
|
|
.Lb libc
|
|
.Sh 書式
|
|
.In machine/param.h
|
|
.In sys/types.h
|
|
.In sys/ipc.h
|
|
.In sys/shm.h
|
|
.Ft void *
|
|
.Fn shmat "int shmid" "const void *addr" "int flag"
|
|
.Ft int
|
|
.Fn shmdt "const 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
|