sem_close

Synopsis

#include <semaphore.h>

int sem_close(sem_t *sem);

Status

Implemented

Conformance

IEEE Std 1003.1-2024

Description

The sem_close() function shall release any state associated with the named semaphore sem, previously returned by sem_open(), and deallocate the memory that call reserved.

If the semaphore has been unlinked with sem_unlink(), closing the last open reference to it also destroys it. sem_close() does not apply to unnamed semaphores; destroy those with sem_destroy().

Using sem after it has been closed has undefined results.

Return value

Upon successful completion, sem_close() shall return 0. Otherwise it shall return -1 and set errno to indicate the error.

Errors

This function shall fail if:

  • EINVAL - sem is a null pointer or does not refer to a named semaphore.

POSIX deviations

No POSIX deviations discovered.