|
|
Power 6/32 Unix version 1.21
.TH SHMGET 2
.SH NAME
shmget \- get shared memory segment
.SH SYNOPSIS
.B #include <sys/types.h>
.br
.B #include <sys/ipc.h>
.br
.B #include <sys/shm.h>
.PP
.nf
.BR "int shmget (key, size, shmflg)
.B key_t key;
.B int size, shmflg;
.fi
.SH DESCRIPTION
.I Shmget
returns the shared memory identifier associated with
.IR key .
.PP
A shared memory identifier and associated data structure and shared memory
segment of size
.I size
bytes (see
.IR intro (2))
is created for
.I key
if one of the following are true:
.IP
.I Key
is equal to
.SM
.BR IPC_PRIVATE .
.IP
.I Key
does not already have a shared memory identifier associated with it, and
.RI ( shmflg " & "
.SM
.BR IPC_CREAT\*S )
is ``true''.
.PP
Upon creation, the data structure associated with the new shared memory
identifier is initialized as follows:
.IP
.BR Shm_perm.cuid ", " shm_perm.uid ,
.BR shm_perm.cgid ", and " shm_perm.gid
are set equal to the effective user
.SM ID
and effective group
.SM ID\*S,
respectively, of the calling process.
.IP
The low-order 9 bits of
.B shm_perm.mode
are set equal to the low-order 9 bits of
.IR shmflg .
.B Shm_segsz
is set equal to the value of
.IR size .
.IP
.BR Shm_lpid ", " shm_nattch ",
.BR shm_atime ", and " shm_dtime "
are set equal to 0.
.IP
.B Shm_ctime
is set equal to the current time.
.PP
.I Shmget
fails if one or more of the following are true:
.TP 15
.SM
.SM
\%[EINVAL]
.I Size
is less than the system-imposed minimum
or greater than the system-imposed maximum.
.TP
.SM
\%[EACCES]
A shared memory identifier exists for
.I key
but operation permission (see
.IR intro (2))
as specified by the low-order 9 bits of
.I shmflg
would not be granted.
.TP
.SM
\%[EINVAL]
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
.SM
\%[ENOENT]
A shared memory identifier does not exist for
.I key
and
.RI ( shmflg " &"
.SM
.BR IPC_CREAT\*S )
is ``false''.
.TP
.SM
\%[ENOSPC]
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
.SM
\%[ENOMEM]
A shared memory identifier and associated shared memory segment are to be
created but the amount of available physical memory is not sufficient to
fill the request.
.TP
.SM
\%[EEXIST]
A shared memory identifier exists for
.I key
but
.RI "((" shmflg " & "
.SM
.BR IPC_CREAT\*S ") and ("
.IR shmflg " & "
.SM
.BR IPC_EXCL\*S "))"
is ``true''.
.br
.ne 7v
.SH "RETURN VALUE"
Upon successful completion,
a non-negative integer,
namely a shared memory identifier is returned.
Otherwise, a value of \-1 is returned and
.I errno\^
is set to indicate the error.
.SH SEE ALSO
intro(2), shmctl(2), shmop(2).
.\" @(#)shmget.2 6.2 of 9/6/83
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.