hpux man page for sem_open

Query: sem_open

OS: hpux

Section: 2

Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar

sem_open(2)							System Calls Manual						       sem_open(2)

NAME
sem_open - create/open a named POSIX semaphore
SYNOPSIS
DESCRIPTION
is used to open or create a named semaphore. A successful call to will create a descriptor for the semaphore specified by name. The pointer to the semaphore returned by can be used to access the semaphore associated with name in subsequent operations. The name argument points to a string referring to a semaphore. It should begin with a "/" and shall conform to pathname rules except that no path component should be "." or "..". The oflag argument specifies whether a semaphore is to be created or not. The following bits in it may be set: If this flag is set, a new semaphore is created if it does not already exist. If this flag is not set, the semaphore should already exist. If this flag is set, the call fails if the semaphore already exists. This flag is valid only when is also set; otherwise, it is ignored. The mode and value arguments are provided to supply the permissions and the initial value information necessary for creating a new sema- phore. To use this function, link in the realtime library by specifying on the compiler or linker command line.
EXAMPLES
The following call to will create a new named semaphore if one does not exist, which depends on the flags specified in oflag, has the per- missions specified in mode and has an initial value of value.
RETURN VALUE
If the semaphore was created and initialized, returns a pointer to a structure containing the index of the new descriptor. If the semaphore could not be created/initialized, the call returns -1 and sets to indicate the error. If the named semaphore is already opened by the calling process, a descriptor and a structure for the named semaphore already exists for the calling process. A new descrip- tor is not created and a pointer to the existing structure is returned for this call.
ERRORS
fails and does not perform the requested operation if any of the following conditions are encountered: [EACCES] The named semaphore exists and the process does not have the permissions to open the semaphore as described by oflag, or the named semaphore does not exist and the process does not have the permission to open it. [EEXIST] The flags and are set in oflag and the named semaphore exists. [EINTR] A signal interrupted the operation. [EINVAL] The argument value is greater than and the flag was specified in oflag. [EINVAL] The name argument does not begin with "/" or contains "." or ".." as a pathname component. [EMFILE] Too many semaphore descriptors are currently in use by this process. [ENAMETOOLONG] The name string is longer than [ENFILE] There are too many semaphores in the system. [ENOENT] The flag is not set in oflag and the named semaphore does not exist. [ENOSPC] There are insufficient resources for the creation of a new named semaphore.
SEE ALSO
sem_close(2), sem_post(2), sem_wait(2), sem_unlink(2), privileges(5), <semaphore.h>.
STANDARDS CONFORMANCE
sem_open(2)
Related Man Pages
sem_open(3c) - opensolaris
sem_close(2) - hpux
sem_close(3) - netbsd
sem_open(3) - netbsd
sem_open(2) - osx
Similar Topics in the Unix Linux Community
Check if file exists, and create file
File shows in ls but cannot be accessed