151 lines
3.6 KiB
Plaintext
151 lines
3.6 KiB
Plaintext
'\"macro stdmacro
|
|
.if n .pH g2.shmget @(#)shmget 41.3 of 5/26/91
|
|
.\" Copyright 1991 UNIX System Laboratories, Inc.
|
|
.\" Copyright 1989, 1990 AT&T
|
|
.nr X
|
|
.if \nX=0 .ds x} shmget 2 "" "\&"
|
|
.if \nX=1 .ds x} shmget 2 ""
|
|
.if \nX=2 .ds x} shmget 2 "" "\&"
|
|
.if \nX=3 .ds x} shmget "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
\f4shmget\f1 \- get shared memory segment identifier
|
|
.SH SYNOPSIS
|
|
\f4#include <sys/types.h>\f1
|
|
.br
|
|
\f4#include <sys/ipc.h>\f1
|
|
.br
|
|
\f4#include <sys/shm.h>\f1
|
|
.PP
|
|
.nf
|
|
\f4int shmget(key_t key, size_t size, int shmflg);\f1
|
|
.fi
|
|
.SH DESCRIPTION
|
|
\f4shmget\fP
|
|
returns the shared memory identifier associated with
|
|
.IR key .
|
|
.\".P
|
|
.\"If the Enhanced Security Utilities are installed and running,
|
|
.\"the \f2key\fP values are kept on a per-level basis; i.e., \f2shmget\fP
|
|
.\"searches only among \f2key\fP values at the same security level as the
|
|
.\"calling process.
|
|
.PP
|
|
A shared memory identifier and associated data structure and shared memory
|
|
segment of at least
|
|
.I size
|
|
bytes [see
|
|
\f4intro\fP(2)]
|
|
are created for
|
|
.I key
|
|
if one of the following are true:
|
|
.IP
|
|
.I key
|
|
is equal to
|
|
\f4IPC_PRIVATE\f1.
|
|
.IP
|
|
.I key
|
|
does not already have a shared memory identifier associated with it, and
|
|
(\f2shmflg\f4&IPC_CREAT\f1)
|
|
is true.
|
|
.PP
|
|
Upon creation, the contents of the shared memory segment
|
|
are initialized to zero,
|
|
and the data structure associated with the new shared memory
|
|
identifier is initialized as follows:
|
|
.IP
|
|
\f4shm_perm.cuid\f1, \f4shm_perm.uid\f1,
|
|
\f4shm_perm.cgid\f1, and \f4shm_perm.gid\f1
|
|
are set equal to the effective user
|
|
.SM ID
|
|
and effective group
|
|
.SM ID\*S,
|
|
respectively, of the calling process.
|
|
.IP
|
|
The access permission bits of
|
|
\f4shm_perm.mode\f1
|
|
are set equal to the access permission bits of
|
|
.IR shmflg .
|
|
\f4shm_segsz\f1
|
|
is set equal to the value of
|
|
.IR size .
|
|
.IP
|
|
\f4shm_lpid\f1, \f4shm_nattch\f1
|
|
\f4shm_atime\f1, and \f4shm_dtime\f1
|
|
are set equal to 0.
|
|
.IP
|
|
\f4shm_ctime\f1
|
|
is set equal to the current time.
|
|
.IP
|
|
.\"If the Enhanced Security Utilities are installed and running,
|
|
.\"an access control list (ACL) is created for the shared memory segment
|
|
.\"and set empty.
|
|
.PP
|
|
\f4shmget\fP
|
|
fails if one or more of the following are true:
|
|
.TP 15
|
|
\f4EINVAL\fP
|
|
.I size
|
|
is less than the system-imposed minimum
|
|
or greater than the system-imposed maximum.
|
|
.TP
|
|
\f4EACCES\fP
|
|
A shared memory identifier exists for
|
|
.I key
|
|
but operation permission [see
|
|
\f4intro\fP(2)]
|
|
as specified by the low-order 9 bits of
|
|
.I shmflg
|
|
would not be granted.
|
|
.TP
|
|
\f4EINVAL\fP
|
|
A shared memory identifier exists for
|
|
.I key
|
|
but the size of the segment associated with it is less than
|
|
.I size
|
|
and
|
|
.I size
|
|
is not equal to zero.
|
|
.TP
|
|
\f4ENOENT\fP
|
|
A shared memory identifier does not exist for
|
|
.I key
|
|
and
|
|
(\f2shmflg\f4&IPC_CREAT\f1)
|
|
is false.
|
|
.TP
|
|
\f4ENOSPC\fP
|
|
A shared memory identifier is to be created but
|
|
the system-imposed limit on the maximum number of
|
|
allowed shared memory identifiers system wide
|
|
would be exceeded.
|
|
.TP
|
|
\f4ENOMEM\fP
|
|
A shared memory identifier and associated shared memory segment are to be
|
|
created but the amount of available memory is not sufficient to
|
|
fill the request.
|
|
.TP
|
|
\f4EEXIST\fP
|
|
A shared memory identifier exists for
|
|
.I key
|
|
but both
|
|
(\f2shmflg\f4&IPC_CREAT\f1)
|
|
and
|
|
(\f2shmflg\f4&IPC_EXCL\f1)
|
|
are true.
|
|
.br
|
|
.ne 7v
|
|
.SH SEE ALSO
|
|
\f4intro\fP(2), \f4shmctl\fP(2), \f4shmop\fP(2), \f4stdipc\fP(3C), \f4ipcs\fP(1), \f4ipcrm\fP(1).
|
|
.SH "DIAGNOSTICS"
|
|
Upon successful completion,
|
|
a non-negative integer,
|
|
namely a shared memory identifier is returned.
|
|
Otherwise, a value of \-1 is returned and
|
|
\f4errno\fP
|
|
is set to indicate the error.
|
|
.SH NOTES
|
|
The user must explicitly remove shared memory segments
|
|
after the last reference to them has been removed.
|
|
.\" @(#)shmget.2 6.2 of 9/6/83
|
|
.Ee
|