PTHREAD_SIGNALS_UNBLOCK_NP(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1

πŸ’… PTHREAD_SIGNALS_BLOCK_NP πŸ’…

okay so bestie, this is a page from the Library Functions Manual, section 3 (yes, pthread_signals_block_np(3) β€” the pthreads girlies live here πŸ’–). Buckle up, because this one is genuinely iconic: it's the fast-lane way to block async signals and I'm obsessed.


✨ NAME ✨

pthread_signals_block_np, pthread_signals_unblock_np β€” fast asynchronous signals blocking and unblocking 🫢

πŸ“š LIBRARY πŸ“š

POSIX Threads Library (libpthread, -lpthread) β€” that's the one you link against, no cap.

πŸŽ€ SYNOPSIS πŸŽ€

#include <pthread_np.h>

void
pthread_signals_block_np(void);

void
pthread_signals_unblock_np(void);

like, both of them take literally nothing and return literally nothing. minimalism ate πŸ”₯

🌸 DESCRIPTION 🌸

So the pthread_signals_block_np() and pthread_signals_unblock_np() functions hand your user programs an interface to the fast asynchronous signals blocking facility sigfastblock(2). it's giving VIP access ✨

Blocking signals with pthread_signals_block_np() disables delivery of any asynchronous signal, until unblocked. Blocking signals establishes a critical section where the execution flow of the thread cannot be diverted into a signal handler. and the best part? blocking signals is fast β€” it's performed by a single memory write into a location established with the kernel. one write. that's it. main character energy πŸ‘‘

⚠️ heads up: synchronous signal delivery cannot be blocked in general, including with these functions. so don't come for them about that πŸ™ˆ

The blocked state established by the pthread_signals_block_np() is not completely POSIX-compliant. specifically: system calls executed while in a blocked section might abort sleep and return EINTR upon queuing of an asynchronous signal to the thread, but the signal handler is not called until the last unblock is done. lowkey a quirk, but that's the vibe πŸ€·β€β™€οΈ

Calls to pthread_signals_block_np can be nested, and must be complemented by an equal count of calls to pthread_signals_unblock_np to return the calling thread to the standard mode of signal receiving. so like... count your blocks, bestie. matching counts or it's not slaying πŸ’€

An example use of these function might be the construction of the CPU state that cannot be done atomically, and which includes stages where the state of the thread is not ABI compliant. if a signal is delivered while such state is not yet finished, signal handlers would misbehave 😭 . Using standard functions (sigprocmask()) to establish critical section might be much slower, because sigprocmask() is system call, while pthread_signals_block_np() consists of a single atomic memory write. literally the glow-up πŸ¦‹

🌈 RETURN VALUES 🌈

The functions do not return a value. nothing. nada. void girlies stay winning ✨

πŸ’œ ERRORS πŸ’œ

There are no errors reported by the functions. zero drama, we love to see it πŸŽ€

πŸ”₯ SEE ALSO πŸ”₯

go read them, iykyk πŸ“–


and that's the whole page bestie!! 🧚 this one's from Debian, dated May 16, 2025, and it's the PTHREAD_SIGNALS_BLOCK_NP(3) page β€” mwah, go block some signals responsibly πŸ’…πŸ’–

πŸ“¦ where this page comes from