Branch
Hash :
e9d8c4f4
Author :
Date :
2025-05-16T15:51:13
sigprocmask: Make multithread-safe on native Windows. * lib/sigprocmask.c: Include glthread/lock.h. (sig_lock): New variable. (blocked_set): Remove 'volatile'. (sigprocmask, _gl_raise_SIGPIPE): Use the sig_lock. * modules/sigprocmask (Depends-on): Add lock. * doc/posix-functions/sigprocmask.texi: Mention the async-safety issue.
@node sigprocmask
@subsection @code{sigprocmask}
@findex sigprocmask
POSIX specification:@* @url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/sigprocmask.html}
Gnulib module: sigprocmask
@mindex sigprocmask
Portability problems fixed by Gnulib:
@itemize
@item
This function is missing on some platforms:
mingw, MSVC 14.
@end itemize
Portability problems not fixed by Gnulib:
@itemize
@item
In case of failure, the return value is wrong on some platforms:
@c https://gnats.netbsd.org/cgi-bin/query-pr-single.pl?number=57213
NetBSD 10.0 when libpthread is in use.
@end itemize
Note: Although @code{sigprocmask} officially has undefined behaviour in
multi-threaded programs, in practice it is essentially equivalent to
@code{pthread_sigmask}, with only a difference regarding the error
return convention. It's simpler to use @code{sigprocmask}, since it does
not require linking with @code{-lpthread} on some platforms:
glibc, NetBSD, OpenBSD, AIX.
Note: While on POSIX platforms, @code{sigprocmask} is multithread-safe
and async-signal safe (cf. POSIX section ``Signal Actions''
@url{https://pubs.opengroup.org/onlinepubs/9799919799/functions/V2_chap02.html#tag_16_04_03}),
the gnulib replacement on native Windows is only multithread-safe,
not async-signal safe.