PTHREAD_SIGNALS_UNBLOCK_NP(3)
π 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
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- π the page's license: BSD-2-Clause
- Copyright (c) 2025 The FreeBSD Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms