Syntax | #include <sys/sem.h> int semctl(int semid, int semnum, int cmd, ...); CRTE111A30 int semctl64(int semid, int semnum, int cmd, ...); (End) | |||||||||||||||||||||
Description |
cmd is used to specify one of the semaphore control operations listed below; semid and semnum are used to specify the semaphore for which the specified operation is to be performed. The access permissions required for a particular operation are shown under the relevant command (see also section “Interprocess communication” ). The type of the fourth argument depends on the value of cmd. The function The struct ipc_perm sem_perm; /* operation permission struct */ struct sem *sem_base; /* ptr to first semaphore in set */ ushort_t sem_nsems; /* # of semaphores in set */ time_t sem_otime; /* last semop time */ time_t sem_ctime; /* last change time */ The elements of the structure time64_t sem_otime; time64_t sem_ctime; The symbolic names for the values for cmd are defined in the header file
The following commands affect every
The following commands are also available:
| |||||||||||||||||||||
Return val. | If successful, | |||||||||||||||||||||
Value of | ||||||||||||||||||||||
if | ||||||||||||||||||||||
Value of | ||||||||||||||||||||||
if | ||||||||||||||||||||||
Value of | ||||||||||||||||||||||
if | ||||||||||||||||||||||
Value of | ||||||||||||||||||||||
if | ||||||||||||||||||||||
0 | if other cmd values were specified. | |||||||||||||||||||||
-1 | if unsuccessful. | |||||||||||||||||||||
Errors |
| |||||||||||||||||||||
| The calling process does not have the required access permission for the command to be executed (see section “Interprocess communication”). | |||||||||||||||||||||
Extension | ||||||||||||||||||||||
| msgp points to an invalid address. (End) | |||||||||||||||||||||
| semid is not a valid semaphore ID, semnum has a value less than 0 or greater | |||||||||||||||||||||
| cmd is equal to | |||||||||||||||||||||
| cmd is equal to | |||||||||||||||||||||
| ||||||||||||||||||||||
|
| cmd is equal to | ||||||||||||||||||||
| ||||||||||||||||||||||
|
| POSIX-BC correction status < A47. | ||||||||||||||||||||
Notes | The fourth argument in the "Syntax" section is identified in XPG4 as ... in order to avoid a clash with the ISO C standard. The fourth argument can be defined by the application programmer as follows: union semun { int val; struct semid_ds *buf; unsigned short *array; } arg; | |||||||||||||||||||||
See also |
|