Files
gnulib/doc/posix-functions/pthread_sigmask.texi
Paul Eggert 12a30be76f pthread_sigmask: lock here, not in sigprocmask
Since sigprocmask should now be used only in single-threaded processes,
move the locking from lib/sigprocmask.c to lib/pthread_sigmask.c.
* lib/pthread_sigmask.c: If !HAVE_SIGPROCMASK &&
!GNULIB_PTHREAD_SIGMASK_SINGLE_THREAD, replace Gnulib sigprocmask
with a thread-safe subsitute sigprocmask_r.
Include glthread/lock.h to implement this.
* lib/sigprocmask.c (gl_lock_define_initialized, gl_lock_lock)
(gl_lock_unlock, sig_lock): Remove.  All uses removed.
Do not include glthread/lock.h.
* m4/signalblocking.m4 (gl_SIGNALBLOCKING):
Define HAVE_SIGPROCMASK, for the benefit of pthread_sigmask.c.
* modules/pthread_sigmask (Depends-on): Add ‘lock’.
* modules/sigprocmask (Depends-on): Remove ‘lock’.
2026-04-05 11:34:34 -07:00

49 lines
1.6 KiB
Plaintext

@node pthread_sigmask
@subsection @code{pthread_sigmask}
@findex pthread_sigmask
POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/pthread_sigmask.html}
Gnulib module: pthread_sigmask
@mindex pthread_sigmask
Portability problems fixed by Gnulib:
@itemize
@item
This function is missing on some platforms:
Minix 3.1.8, mingw, MSVC 14.
@item
This function is declared in @code{<pthread.h>} instead of @code{<signal.h>}
on some platforms:
FreeBSD 6.4, OpenBSD 3.8.
@item
This function requires compiling with @code{-pthread} and/or
linking with @code{-lpthread} on some platforms:
glibc 2.31, NetBSD, OpenBSD 5.8.
@item
This function does nothing and always returns 0 in programs that are not
linked with @code{-lpthread} on some platforms:
FreeBSD 14.0, MidnightBSD 1.1, HP-UX 11.31, Solaris 9.
@item
When it fails, this function returns @minus{}1 instead of the error number on
some platforms:
Cygwin 1.7.5,
@c https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57214
NetBSD 9.3 when libpthread is not in use.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
On platforms that do not natively support this function,
it has unspecified behavior in a multi-threaded process.
For example, the Gnulib replacement on native MS-Windows can affect
the signal masks of other threads, which can lead to race conditions.
@item
The Gnulib replacement on native MS-Windows is not async-signal-safe
(see
@url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_04_03,
POSIX section ``Signal Actions''}).
@end itemize