semget.2
来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 139 行
2
139 行
.\" SCCSID: @(#)semget.2 8.1 9/11/90.TH semget 2.SH Namesemget \- get set of semaphores.SH Syntax.nf.ft B#include <sys/types.h>#include <sys/ipc.h>#include <sys/sem.h>.PP.ft Bint semget (\fIkey, nsems, semflg\fP)key_t \fIkey\fP;int \fInsems, semflg\fP;.fi.SH Description.NXR "semget system call".NXA "semget system call" "ftok subroutine".NXA "semget system call" "semctl system call".NXA "semget system call" "semop system call".NXR "semaphore" "getting"The.PN semgetsystem callreturns the semaphore identifier associated with.IR key .A semaphore identifier and associated data structure and set containing .I nsemssemaphores are created for.IR key , if one of the following is true:.IP \(bu 4The.I keyis equal to IPC_PRIVATE.IP \(buThe.I keydoes not already have a semaphore identifier associated with it, and.RI ( semflg& IPC_CREAT )is true..PPFor further information, see .MS intro 2 ..PPUpon creation,the data structure associated with the new semaphore identifieris initialized as follows:.IP \(bu 4The.BR sem_perm.cuid ,.BR sem_perm.uid ,.BR sem_perm.cgidand.B sem_perm.gidare set equal to the effective user ID and effective group ID, respectively, ofthe calling process..IP \(bu 4The low-order nine bits of.B sem_perm.modeare set equal to the low-order nine bits of.IR semflg ..IP \(bu 4The.B sem_nsems is set equal to the value of.I nsems..IP \(bu 4The.B sem_otimeis set equal to zero (0) and.B sem_ctime is set equal to the current time..SH Return ValuesUpon successful completion, a nonnegative integer, namely a semaphoreidentifier, is returned. Otherwise, a value of \-1 is returned and .I errnois set to indicate the error..SH Diagnostics.NXR "semget system call" "diagnostics"The.I semgetsystem callfails if any of the following is true:.TP 15[EINVAL]The.I nsemsis either less than or equal to zero or greater than the system-imposed limit.TP 15[EACCES]A semaphore identifier exists for.IR key ,but operation permission,as specified by the low-order nine bits of.I semflgwould not be granted. For further information, see .MS errno 2 ..TP 15[EINVAL]A semaphore identifier exists for.IR key ,but the number of semaphores in the set associated with it is less than .I nsemsand.I nsemsis not equal to zero. .TP 15[ENOENT]A semaphore identifier does not exist for.I key and .RI ( semflg& IPC_CREAT )is false. .TP 15[ENOSPC]A semaphore identifier is to be createdbut the system-imposed limit on themaximum number of allowed semaphoreidentifiers in the system would be exceeded..TP 15[EEXIST]A semaphore identifier exists for.I keybut .RI (( semflg& IPC_CREAT )& .RI ( semflg& IPC_EXCL ))is true. .SH See Alsosemctl(2), semop(2), ftok(3)
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?