NAME
sseemmooppeenn - initialize and open a named semaphore
SYNOPSIS
##iinncclluuddee <
semt * sseemmooppeenn(const char *name, int oflag, ...); The parameters "modet mode" and "unsigned int value" are optional.> DESCRIPTION
The named semaphore named name is initialized and opened as specified by the argument oflag and a semaphore descriptor is returned to the calling process. The value of oflag is formed by or'ing the following values: OCREAT create the semaphore if it does not exist OEXCL error if create and semaphore exists If OCREAT is specified, sseemmooppeenn() requires an additional two arguments. mode specifies the permissions for the semaphore as described in chmod(2) and modified by the process' umask value (see umask(2)). The semaphore is created with an initial value, which must be less than or equal to SEMVALUEMAX. If OEXCL is specified and the semaphore exists, sseemmooppeenn() fails. Thecheck for the existence of the semaphore and the creation of the sema-
phore are atomic with respect to all processes calling sseemmooppeenn() with OCREAT and OEXCL set. When a new semaphore is created, it is given the user ID and group ID which correspond to the effective user and group IDs of the calling process. There is no visible entry in the file system for the created object in this implementation. The returned semaphore descriptor is available to the calling process until it is closed with sseemmcclloossee(), or until the caller exits or execs.If a process makes repeated calls to sseemmooppeenn(), with the same name argu-
ment, the same descriptor is returned for each successful call, unless sseemmuunnlliinnkk() has been called on the semaphore in the interim. If sseemmooppeenn() fails for any reason, it will return a value of SEMFAILED and sets errno. On success, it returns a semaphore descriptor. EERRRROORRSS The named semaphore is opened unless: [EACCES] The required permissions (for reading and/or writing)are denied for the given flags; or OCREAT is speci-
fied, the object does not exist, and permission to create the semaphore is denied. [EEXIST] OCREAT and OEXCL were specified and the semaphore exists. [EINTR] The sseemmooppeenn() operation was interrupted by a signal. [EINVAL] The sshhmmooppeenn() operation is not supported; or OCREAT is specified and value exceeds SEMVALUEMAX.[EMFILE] The process has already reached its limit for sema-
phores or file descriptors in use.[ENAMETOOLONG] name exceeded SEMNAMELEN characters.
[ENFILE] Too many semaphores or file descriptors are open on the system. [ENOENT] OCREAT is not set and the named semaphore does not exist. [ENOSPC] OCREAT is specified, the file does not exist, and there is insufficient space available to create the semaphore.SEE ALSO
semclose(2), sempost(2), semtrywait(2), semunlink(2), semwait(2), semctl(2), semget(2), semop(2), umask(2) HISTORY sseemmooppeenn() is specified in the POSIX Realtime Extension(1003.1b-1993/1003.1i-1995).
Darwin June 8, 2000 Darwin