Paul Eggert wrote: > For years, POSIX has recommended that multithreaded apps use > pthread_sigmask instead of sigprocmask.
Another easy case is the 'spawn-pipe' module. Again, adding $(PTHREAD_SIGMASK_LIB) to the link requirements is redundant. 2026-04-04 Bruno Haible <[email protected]> spawn-pipe: Prefer pthread_sigmask over sigprocmask. Suggested by Paul Eggert. * lib/spawn-pipe.c (execute): Use pthread_sigmask to get the set of blocked signals. * modules/spawn-pipe (Depends-on): Add pthread_sigmask. diff --git a/lib/spawn-pipe.c b/lib/spawn-pipe.c index ea03586ce7..f1f65852e3 100644 --- a/lib/spawn-pipe.c +++ b/lib/spawn-pipe.c @@ -450,13 +450,14 @@ create_pipe (const char *progname, } # endif +# if !(defined _WIN32 && !defined __CYGWIN__) sigset_t blocked_signals; +# endif if (slave_process) { - /* FIXME: Use pthread_sigmask, not sigprocmask, as the two functions - behave differently on macOS and the sigprocmask behavior can cause - this thread to race with other threads in harmful ways. */ - sigprocmask (SIG_SETMASK, NULL, &blocked_signals); +# if !(defined _WIN32 && !defined __CYGWIN__) + pthread_sigmask (SIG_SETMASK, NULL, &blocked_signals); +# endif block_fatal_signals (); } diff --git a/modules/spawn-pipe b/modules/spawn-pipe index 749fa619db..eff353ede2 100644 --- a/modules/spawn-pipe +++ b/modules/spawn-pipe @@ -37,6 +37,7 @@ posix_spawnattr_setpgroup posix_spawnattr_setsigmask posix_spawnattr_setflags posix_spawnattr_destroy +pthread_sigmask bool stdlib-h streq
