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

216 lines
4.9 KiB
Groff

'\"macro stdmacro
.if n .pH g2.semctl @(#)semctl 41.4 of 5/26/91
.\" Copyright 1991 UNIX System Laboratories, Inc.
.\" Copyright 1989, 1990 AT&T
.nr X
.if \nX=0 .ds x} semctl 2 "" "\&"
.if \nX=1 .ds x} semctl 2 ""
.if \nX=2 .ds x} semctl 2 "" "\&"
.if \nX=3 .ds x} semctl "" "" "\&"
.TH \*(x}
.tr ~
.SH NAME
\f4semctl\f1 \- semaphore control operations
.SH SYNOPSIS
\f4#include <sys/types.h>\f1
.br
\f4#include <sys/ipc.h>\f1
.br
\f4#include <sys/sem.h>\f1
.PP
\f4union semun {\f1
.br
\f4~~~~~int val;\f1
.br
\f4~~~~~struct semid_ds \(**buf;\f1
.br
\f4~~~~~ushort \(**array;\f1
.br
\f4};\f1
.PP
\f4int semctl(int semid, int semnum, int cmd, ... /\(** union semun arg \(**/);\f1
.tr ~~
.SH DESCRIPTION
\f4semctl\fP
provides a variety of semaphore control operations as specified by
.IR cmd .
.PP
The following
.IR cmd s
are executed with respect to the semaphore specified by
.IR semid " and " semnum:
.RS
.TP \w'\f4IPC_RMID\fP\ \ \ 'u
\f4GETVAL\f1
Return the value of \f4semval\fP [see
\f4intro\fP(2)].
.SM {READ}
.TP \w'\f4IPC_RMID\fP\ \ \ 'u
\f4SETVAL\f1
Set the value of \f4semval\fP to
\f2arg.\f4val\f1.
.SM {ALTER}.
When this command is successfully executed, the \f4semadj\fP value corresponding to the
specified semaphore in all processes is cleared.
.TP \w'\f4IPC_RMID\fP\ \ \ 'u
\f4GETPID\f1
Return the value of \f4(int) sempid\f1.
.SM {READ}
.TP \w'\f4IPC_RMID\fP\ \ \ 'u
\f4GETNCNT\f1
Return the value of \f4semncnt\f1.
.SM {READ}
.TP \w'\f4IPC_RMID\fP\ \ \ 'u
\f4GETZCNT\f1
Return the value of \f4semzcnt\f1.
.SM {READ}
.RE
.PP
The following
.IR cmd s
return and set, respectively, every \f4semval\fP in the set of semaphores.
.RS
.TP \w'\f4IPC_RMID\fP\ \ \ 'u
\f4GETALL\f1
Place \f4semval\fPs into array pointed to by
\f2arg.\f4array\f1.
.SM {READ}
.TP \w'\f4IPC_RMID\fP\ \ \ 'u
\f4SETALL\f1
Set \f4semval\fPs according to the array pointed to by
\f2arg.\f4array\f1.
.SM {ALTER}.
When this cmd is successfully executed, the \f4semadj\fP values corresponding to each
specified semaphore in all processes are cleared.
.RE
.PP
The following
.IR cmd s
are also available:
.RS
.TP \w'\f4IPC_RMID\fP\ \ \ 'u
\f4IPC_STAT\f1
Place the current value of each member of the data structure associated with
.I semid
into the structure pointed to by
\f2arg.\f4buf\f1.
The contents of this structure are defined in
\f4intro\fP(2).
.SM {READ}
.TP \w'\f4IPC_RMID\fP\ \ \ 'u
\f4IPC_SET\f1
Set the value of the following members of the data structure associated with
.I semid
to the corresponding value found in the structure pointed to by
\f2arg.\f4buf\f1:
.nf
.IP "" \w'\f4IPC_RMID\fP\ \ \ \ \ \ \ 'u
\f4sem_perm.uid\f1
\f4sem_perm.gid\f1
\f4sem_perm.mode /\(** only access permission bits \(**/\f1
.fi
.IP "" \w'\f4IPC_RMID\fP\ \ \ 'u
This command can be executed only by a process that has an effective user
.SM ID
equal to the value of \f4sem_perm.cuid\f1 or \f4sem_perm.uid\f1
in the data structure associated with \f2semid\fP
or to a process that has the \f4super-user\fP privilege.
.TP \w'\f4IPC_RMID\fP\ \ \ 'u
\f4IPC_RMID\f1
Remove the semaphore identifier specified by
.I semid
from the system and destroy the set of semaphores and data structure
associated with it.
This command can be executed only by a process that has an effective user
.SM ID
equal to the value of \f4sem_perm.cuid\f1 or \f4sem_perm.uid\f1
in the data structure associated with \f2semid\fP
or to a process that has the \f4super-user\fP privilege.
.RE
.PP
\f4semctl\fP
fails if one or more of the following are true:
.TP 15
\f4EACCES\fP
Operation permission is denied to the calling process [see
\f4intro\fP(2)].
.TP 15
\f4EINVAL\fP
.I semid
is not a valid semaphore identifier.
.TP
\f4EINVAL\fP
.I semnum
is less than 0 or greater than
\f4sem_nsems\f1.
.TP
\f4EINVAL\fP
.I cmd
is not a valid command.
.TP
\f4EINVAL\fP
\f2cmd\f1 is \f4IPC_SET\fP and \f4sem_perm.uid\fP or \f4sem_perm.gid\fP
is not valid.
.TP
\f4EOVERFLOW\fP
\f2cmd\f1 is \f4IPC_STAT\fP and \f2uid\f1 or \f2gid\f1 is too large to
be stored in the structure pointed to by \f2arg.buf\f1.
.TP
\f4ERANGE\fP
.I cmd
is
\f4SETVAL\f1
or
\f4SETALL\f1
and the value to which \f4semval\fP is to be set is greater than
the system imposed maximum.
.TP
\f4EPERM\fP
.I cmd
is equal to
\f4IPC_RMID\f1
or
\f4IPC_SET\f1
and the effective user
.SM ID
of the calling process is not equal
to the value of \f4sem_perm.cuid\f1 or \f4sem_perm.uid\f1
in the data structure associated with \f2semid\fP
and the calling process does not have \f4super-user\fP privilege.
.TP
\f4EFAULT\fP
\f2arg\f4.buf\f1
points to an illegal address.
.SH SEE ALSO
\f4intro\fP(2), \f4semget\fP(2), \f4semop\fP(2).
.SH "DIAGNOSTICS"
Upon successful completion,
the value returned depends on
.I cmd\^
as follows:
.PD 0
.RS
.TP 1.0i
\f4GETVAL\f1
the value of \f4semval\f1
.TP
\f4GETPID\f1
the value of \f4(int) sempid\f1
.TP
\f4GETNCNT\f1
the value of \f4semncnt\f1
.TP
\f4GETZCNT\f1
the value of \f4semzcnt\f1
.TP
all others
a value of 0
.RE
.PP
.PD
Otherwise, a value of \-1 is returned and
\f4errno\fP
is set to indicate the error.
.\" @(#)semctl.2 6.2 of 9/6/83
.Ee