From 701eb0a0cadd278466d179ae1d74d089ffaf25fd Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Mon, 8 May 2023 02:33:59 -0400 Subject: [core] modify use of posix_spawnattr_setsigdefault modify use of posix_spawnattr_setsigdefault() on __linux__ Subprocesses (CGI scripts and backends FastCGI, SCGI, proxy, etc) which spawned their own children and accidentally relied on inheriting SA_RESTART on SIGCHLD from lighttpd will now have to set that flag themselves, if desired. From a quick survey: - bash sets SA_RESTART on SIGCHLD. - Perl and Python unconditionally reset signals. (Other interpreters are expected to do so as well.) --- src/fdevent.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src') diff --git a/src/fdevent.c b/src/fdevent.c index f9de595e..85de850a 100644 --- a/src/fdevent.c +++ b/src/fdevent.c @@ -516,6 +516,14 @@ pid_t fdevent_fork_execve(const char *name, char *argv[], char *envp[], int fdin #endif && 0 == (rc = sigemptyset(&sigs)) && 0 == (rc = posix_spawnattr_setsigmask(&attr, &sigs)) + #ifdef __linux__ + /* linux appears to walk all signals and to query and preserve some + * sigaction flags even if setting to SIG_DFL, though if specified + * in posix_spawnattr_setsigdefault(), resets to SIG_DFL without query. + * Therefore, resetting all signals results in about 1/2 the syscalls. + * (FreeBSD appears more efficient. Unverified on other platforms.) */ + && 0 == (rc = sigfillset(&sigs)) + #else /*(force reset signals to SIG_DFL if server.c set to SIG_IGN)*/ #ifdef SIGTTOU && 0 == (rc = sigaddset(&sigs, SIGTTOU)) @@ -528,6 +536,7 @@ pid_t fdevent_fork_execve(const char *name, char *argv[], char *envp[], int fdin #endif && 0 == (rc = sigaddset(&sigs, SIGPIPE)) && 0 == (rc = sigaddset(&sigs, SIGUSR1)) + #endif && 0 == (rc = posix_spawnattr_setsigdefault(&attr, &sigs))) { #if defined(HAVE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSEFROM_NP) \ -- cgit v1.2.1