diff options
author | Glenn Strauss <gstrauss@gluelogic.com> | 2023-05-08 02:33:59 -0400 |
---|---|---|
committer | Glenn Strauss <gstrauss@gluelogic.com> | 2023-05-08 03:52:42 -0400 |
commit | 701eb0a0cadd278466d179ae1d74d089ffaf25fd (patch) | |
tree | b4973cd566f1eb4e0cedb51976589ead1f4b6ff6 | |
parent | c2349f149fd85f0e7745831ec9b9d4fcced42591 (diff) | |
download | lighttpd-git-701eb0a0cadd278466d179ae1d74d089ffaf25fd.tar.gz |
[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.)
-rw-r--r-- | src/fdevent.c | 9 |
1 files changed, 9 insertions, 0 deletions
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) \ |