mirror of
https://github.com/freebsd/freebsd-src
synced 2024-11-05 18:22:52 +00:00
138 lines
3.9 KiB
Groff
138 lines
3.9 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.
|
|
.\"
|
|
.\" $Id: shmget.2,v 1.1 1995/10/03 19:17:21 joerg Exp $
|
|
.\"
|
|
.Dd July 3, 1995
|
|
.Dt SHMGET 2
|
|
.Os FreeBSD
|
|
.Sh NAME
|
|
.Nm shmget
|
|
.Nd obtain a shared memory identifier
|
|
.Sh SYNOPSIS
|
|
.Fd #include <sys/types.h>
|
|
.Fd #include <sys/ipc.h>
|
|
.Fd #include <sys/shm.h>
|
|
.Ft int
|
|
.Fn "shmget" "key_t key" "int size" "int flag"
|
|
.Sh DESCRIPTION
|
|
Based on the values of
|
|
.Fa key
|
|
and
|
|
.Fa flag ,
|
|
.Fn shmget
|
|
returns the identifier of a newly created or previously existing shared
|
|
memory segment.
|
|
.\"
|
|
.\" The following bit about keys and modes also applies to semaphores
|
|
.\" and message queues.
|
|
.\"
|
|
The key
|
|
is analogous to a filename: it provides a handle that names an
|
|
IPC object. There are three ways to specify a key:
|
|
.Bl -bullet
|
|
.It
|
|
IPC_PRIVATE may be specified, in which case a new IPC object
|
|
will be created.
|
|
.It
|
|
An integer constant may be specified. If no IPC object corresponding
|
|
to
|
|
.Fa key
|
|
is specified and the IPC_CREAT bit is set in
|
|
.Fa flag ,
|
|
a new one will be created.
|
|
.It
|
|
.Fn ftok
|
|
may be used to generate a key from a pathname. See
|
|
.Xr ftok 3 .
|
|
.El
|
|
.Pp
|
|
The mode of a newly created IPC object is determined by
|
|
.Em OR Ns 'ing
|
|
the following constants into the
|
|
.Fa flag
|
|
parameter:
|
|
.Bl -tag -width XSHM_WXX6XXX
|
|
.It Dv SHM_R
|
|
Read access for user.
|
|
.It Dv SHM_W
|
|
Write access for user.
|
|
.It Dv (SHM_R>>3)
|
|
Read access for group.
|
|
.It Dv (SHM_W>>3)
|
|
Write access for group.
|
|
.It Dv (SHM_R>>6)
|
|
Read access for other.
|
|
.It Dv (SHM_W>>6)
|
|
Write access for other.
|
|
.El
|
|
.\"
|
|
.\" XXX - we should also mention how uid, euid, and gid affect ownership
|
|
.\" and use
|
|
.\"
|
|
.\" end section about keys and modes
|
|
.\"
|
|
.Pp
|
|
When creating a new shared memory segment,
|
|
.Fa size
|
|
indicates the desired size of the new segment in bytes. The size
|
|
of the segment may be rounded up to a multiple convenient to the
|
|
kernel (i.e., the page size).
|
|
.Sh RETURN VALUES
|
|
Upon successful completion,
|
|
.Fn shmget
|
|
returns the positive integer identifier of a shared memory segment.
|
|
Otherwise, -1 is returned and
|
|
.Va errno
|
|
set to indicate the error.
|
|
.Sh ERRORS
|
|
.Fn Shmget
|
|
will fail if:
|
|
.Bl -tag -width Er
|
|
.\"
|
|
.\" XXX What about ipcperm failing?
|
|
.\"
|
|
.It Bq Er EINVAL
|
|
Size specified is greater than the size of the previously existing segment.
|
|
Size specified is less than the system imposed minimum, or greater than
|
|
the system imposed maximum.
|
|
.It Bq Er ENOENT
|
|
No shared memory segment was found matching
|
|
.Fa key ,
|
|
and IPC_CREAT was not specified.
|
|
.It Bq Er ENOSPC
|
|
The kernel was unable to allocate enough memory to
|
|
satisfy the request.
|
|
.It Bq Er EEXIST
|
|
IPC_CREAT and IPC_EXCL were specified, and a shared memory segment
|
|
corresponding to
|
|
.Fa key
|
|
already exists.
|
|
.Pp
|
|
.Sh "SEE ALSO"
|
|
.Xr shmctl 2 ,
|
|
.Xr shmat 2 ,
|
|
.Xr shmdt 2 ,
|
|
.Xr ftok 3
|