1.\" Copyright (c) 2025 The FreeBSD Foundation 2.\" All rights reserved. 3.\" 4.\" SPDX-License-Identifier: BSD-2-Clause 5.\" 6.\" This documentation was written by 7.\" Konstantin Belousov <kib@FreeBSD.org> under sponsorship 8.\" from the FreeBSD Foundation. 9.\" 10.Dd May 16, 2025 11.Dt PTHREAD_SIGNALS_BLOCK_NP 3 12.Os 13.Sh NAME 14.Nm pthread_signals_block_np , 15.Nm pthread_signals_unblock_np 16.Nd fast asynchronous signals blocking and unblocking 17.Sh LIBRARY 18.Lb libpthread 19.Sh SYNOPSIS 20.In pthread_np.h 21.Ft void 22.Fn pthread_signals_block_np "void" 23.Ft void 24.Fn pthread_signals_unblock_np "void" 25.Sh DESCRIPTION 26The 27.Fn pthread_signals_block_np 28and 29.Fn pthread_signals_unblock_np 30functions provide user programs an interface to the fast asynchronous 31signals blocking facility 32.Xr sigfastblock 2 . 33.Pp 34Blocking signals with 35.Fn pthread_signals_block_np 36disables delivery of any asynchronous signal, until unblocked. 37Signal blocking establishes a critical section where the execution 38flow of the thread cannot be diverted into a signal handler. 39Blocking signals is fast, it is performed by a single memory write into 40a location established with the kernel. 41.Pp 42Synchronous signal delivery cannot be blocked in general, including with 43these functions. 44.Pp 45The blocked state established by the 46.Fn pthread_signals_block_np 47is not completely POSIX-compliant. 48Specifically, system calls executed while in a blocked section, 49might abort sleep and return 50.Er EINTR 51upon queuing of an asynchronous signal to the thread, 52but the signal handler is not called until the last unblock is done. 53.Pp 54Calls to 55.Nm pthread_signals_block_np 56can be nested, and must be complemented by an equal count of 57calls to 58.Nm pthread_signals_unblock_np 59to return the calling thread to the standard mode of signal receiving. 60.Pp 61An example use of these function might be the construction of the CPU 62state that cannot be done atomically, and which includes stages where 63the state of the thread is not ABI compliant. 64If a signal is delivered while such state is not yet finished, signal 65handlers would misbehave. 66Using standard functions 67.Pq Fn sigprocmask 68to establish critical section might be much slower, because 69.Fn sigprocmask 70is system call, while 71.Fn pthread_signals_block_np 72consists of a single atomic memory write. 73.Sh RETURN VALUES 74The functions do not return a value. 75.Sh ERRORS 76There are no errors reported by the functions. 77.Sh SEE ALSO 78.Xr sigfastblock 2 , 79.Xr sigprocmask 2 , 80.Xr pthread_sigmask 3 , 81.Xr pthread_np 3 82