---
name: "sem_post"
section: "2"
platform: "macos"
package: "xnu"
version: "12377.121.6"
release: "macOS 26.5"
platforms: ["macos"]
url: "https://new.carta.tech/sem_post"
---

# sem\_post(2)

unlock a semaphore

## NAME

**sem\_post** – unlock a semaphore

## SYNOPSIS

**#include \<semaphore.h\>**

*int*\

**sem\_post**(*sem\_t \*sem*);

## DESCRIPTION

The semaphore referenced by *sem* is unlocked, the value of the semaphore is incremented, and all threads which are waiting on the semaphore are awakened.

**sem\_post**() is reentrant with respect to signals and may be called from within a signal hanlder.

If successful, **sem\_post**() will return 0.  Otherwise, -1 is returned and *errno* is set.

## ERRORS

**sem\_post**() succeeds unless:

- \[EINVAL\]

  *sem* is not a valid semaphore descriptor.

## SEE ALSO

[sem\_open(2)](/sem_open/2.md), sem\_trywait(2), [sem\_wait(2)](/sem_wait/2.md), [semctl(2)](/semctl/2.md), [semget(2)](/semget/2.md), [semop(2)](/semop/2.md)

## HISTORY

**sem\_post**() is specified in the POSIX Realtime Extension (1003.1b-1993/1003.1i-1995).
