1
0
Files
irix-657m-src/eoe/man/man2/semget.2
2022-09-29 17:59:04 +03:00

140 lines
3.2 KiB
Groff

'\"macro stdmacro
.if n .pH g2.semget @(#)semget 41.3 of 5/26/91
.\" Copyright 1991 UNIX System Laboratories, Inc.
.\" Copyright 1989, 1990 AT&T
.nr X
.if \nX=0 .ds x} semget 2 "" "\&"
.if \nX=1 .ds x} semget 2 ""
.if \nX=2 .ds x} semget 2 "" "\&"
.if \nX=3 .ds x} semget "" "" "\&"
.TH \*(x}
.SH NAME
\f4semget\f1 \- get set of semaphores
.SH SYNOPSIS
\f4#include <sys/types.h>\f1
.br
\f4#include <sys/ipc.h>\f1
.br
\f4#include <sys/sem.h>\f1
.PP
.nf
\f4int semget(key_t key, int nsems, int semflg); \f1
.fi
.SH DESCRIPTION
\f4semget\fP
returns the semaphore 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., \f4semget\fP
.\"searches only among \f2key\fP values at the level of the calling
.\"process.
.PP
A semaphore identifier and associated data structure and set containing
.I nsems
semaphores
[see
\f4intro\fP(2)]
are created for
.I key
if one of the following is true:
.IP
.I key
is equal to
\f4IPC_PRIVATE\f1.
.IP
.I key
does not already have a semaphore identifier associated with it, and
(\f2semflg\f4&IPC_CREAT\f1)
is true.
.PP
On creation, the data structure associated with the new semaphore
identifier is initialized as follows:
.IP
\f4sem_perm.cuid\f1, \f4sem_perm.uid\f1,
\f4sem_perm.cgid\f1, and \f4sem_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
\f4sem_perm.mode\f1
are set equal to the access permission bits of
.IR semflg .
.IP
\f4sem_nsems\f1
is set equal to the value of
.IR nsems .
.IP
\f4sem_otime\f1
is set equal to 0 and
\f4sem_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 semaphore and set empty.
.PP
\f4semget\fP
fails if one or more of the following are true:
.TP 15
\f4EINVAL\fP
.I nsems
is either less than or equal to zero or greater than the system-imposed limit.
.TP
\f4EACCES\fP
A semaphore identifier exists for
.IR key ,
but operation permission [see
\f4intro\fP(2)]
as specified by the low-order 9 bits of
.I semflg
would not be granted.
.TP
\f4EINVAL\fP
A semaphore identifier exists for
.IR key ,
but the number of semaphores in the set associated with it is less than
.IR nsems ,
and
.I nsems
is not equal to zero.
.TP
\f4ENOENT\fP
A semaphore identifier does not exist for
.I key
and
(\f2semflg\f4&IPC_CREAT\f1)
is false.
.TP
\f4ENOSPC\fP
A semaphore identifier is to be created but
the system-imposed limit on the maximum number of
allowed semaphore identifiers system wide
would be exceeded.
.TP
\f4ENOSPC\fP
A semaphore identifier is to be created but
the system-imposed limit on the maximum number of
allowed semaphores system wide
would be exceeded.
.TP
\f4EEXIST\fP
A semaphore identifier exists for
.I key
but both
(\f2semflg\f4&IPC_CREAT\f1) and (\f2semflg\f4&IPC_EXCL\f1)
are both true.
.SH SEE ALSO
\f4intro\fP(2), \f4semctl\fP(2), \f4semop\fP(2), \f4stdipc\f1(3C).
.SH "DIAGNOSTICS"
Upon successful completion,
a non-negative integer,
namely a semaphore identifier, is returned.
Otherwise, a value of \-1 is returned and
\f4errno\fP
is set to indicate the error.
.\" @(#)semget.2 6.2 of 9/6/83
.Ee