DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH
 

opensem(S)


opensem -- opens a semaphore

Syntax

cc ... -lx

int opensem (sem_name)
char *sem_name;

Description

opensem opens a semaphore named by sem_name and returns the unique semaphore identification number sem_num used by waitsem and sigsem. creatsem should always be called to initialize the semaphore before the first attempt to open it.

System compatibility

opensem can only be used to open semaphores created under UNIX version 3.0, not for UNIX System V semaphores.

Diagnostics

opensem returns a value of -1 if an error occurs. If the semaphore named does not exist, errno is set to ENOENT. If the file specified is not a semaphore file (i.e., a file previously created by a process using a call to creatsem), errno is set to ENOTNAM. If the semaphore has become invalid due to inappropriate use, errno is set to ENAVAIL.

Notes

This feature is a XENIX specific enhancement which may not be present in all UNIX implementations.

Warning

It is not advisable to open the same semaphore more than once. Although it is possible to do this, it may result in a serious deadlock.

See also

creatsem(S), sigsem(S), waitsem(S)

Standards conformance

opensem is not part of any currently supported standard; it is an extension of AT&T System V provided by the Santa Cruz Operation.
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003