DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 

sem_close(S-osr5)


sem_close -- close a named semaphore

Syntax

cc . . . -lsuds
#include <semaphore.h>

int sem_close(sem_t *sem);

Description

The sem_close function is used to indicate that the calling process has finished using the named semaphore indicated by sem. The sem_close function deallocates (that is, makes available for reuse by a subsequent sem_open(S-osr5) by this process) any system resources allocated by the system for use by this process for this semaphore. If the semaphore has not been removed with a successful call to sem_unlink(S-osr5), then sem_close has no effect on the state of the semaphore. If the sem_unlink function has been successfully invoked for name after the most recent call to sem_open with O_CREAT for this semaphore, then when all processes that have opened the semaphore close it, the semaphore is no longer accessible.

Return values

Upon successful completion, a value of zero is returned. Otherwise, a value of -l is returned and errno is set to indicate the error.

Diagnostics

If the following condition occurs, the sem_close function returns -1 and sets errno to the corresponding value:

[EINVAL]
The sem argument is not a valid semaphore descriptor.

See also

semaphore(FP), sem_init(S-osr5), sem_open(S-osr5), sem_unlink(S-osr5)

Standards conformance

Text reprinted and/or adapted from IEEE Std 1003.1b-1993, IEEE Standard for Information Technology, POSIX Part 1: System Application Program Interface (API) Amendment 1: Realtime Extensions [C Language], copyright © 1993 by the Institute of Electrical and Electronics Engineers, Inc. The IEEE takes no responsibility for and will assume no liability for damages resulting from the reader's misinterpretation of said information resulting from the placement and context in this publication. Information is reproduced with the permission of the IEEE.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005