Paul Eggert wrote: > For years, POSIX has recommended that multithreaded apps use > pthread_sigmask instead of sigprocmask.
This patch does it for the 'execute' module. This is an easy case. Note that there's no need to add $(PTHREAD_SIGMASK_LIB) to the link requirements of the 'execute' module, since these already contain $(LIBTHREAD), and $(PTHREAD_SIGMASK_LIB) is a subset of $(LIBTHREAD). (That's because on all platforms except AIX, $(PTHREAD_SIGMASK_LIB) is empty, whereas on AIX, both $(PTHREAD_SIGMASK_LIB) and $(LIBTHREAD) are '-lpthread'.) 2026-04-04 Bruno Haible <[email protected]> execute: Prefer pthread_sigmask over sigprocmask. Suggested by Paul Eggert. * lib/execute.c (execute): Use pthread_sigmask to get the set of blocked signals. * modules/execute (Depends-on): Add pthread_sigmask. diff --git a/lib/execute.c b/lib/execute.c index a6cc6c6bc7..e178df3c24 100644 --- a/lib/execute.c +++ b/lib/execute.c @@ -261,7 +261,9 @@ execute (const char *progname, equivalent. */ char **child_environ; char **malloced_environ; +# if !(defined _WIN32 && !defined __CYGWIN__) sigset_t blocked_signals; +# endif posix_spawn_file_actions_t actions; bool actions_allocated; posix_spawnattr_t attrs; @@ -283,10 +285,9 @@ execute (const char *progname, 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 (); } actions_allocated = false; diff --git a/modules/execute b/modules/execute index 40dc5ce34d..e63bb5ff46 100644 --- a/modules/execute +++ b/modules/execute @@ -29,6 +29,7 @@ posix_spawnattr_init posix_spawnattr_setsigmask posix_spawnattr_setflags posix_spawnattr_destroy +pthread_sigmask bool stdlib-h sys_wait-h
