1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

cgi: tidy up fastcgi_cleanup signal handler (#13026)

* signal handlers can only touch global volatile sig_atomic_t variables.
* fastcgi_cleanup is static
* structs sigaction are static
* A signal handler cannot call exit() because it is not async signal safe,
  call _exit instead.
This commit is contained in:
Cristian Rodríguez
2024-02-02 14:10:34 -03:00
committed by GitHub
parent f359c0b115
commit eb238577f1

View File

@@ -97,7 +97,7 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS;
#ifndef PHP_WIN32
/* XXX this will need to change later when threaded fastcgi is implemented. shane */
struct sigaction act, old_term, old_quit, old_int;
static struct sigaction act, old_term, old_quit, old_int;
#endif
static void (*php_php_import_environment_variables)(zval *array_ptr);
@@ -116,7 +116,7 @@ static int parent = 1;
#ifndef PHP_WIN32
/* Did parent received exit signals SIG_TERM/SIG_INT/SIG_QUIT */
static int exit_signal = 0;
static volatile sig_atomic_t exit_signal = 0;
/* Is Parent waiting for children to exit */
static int parent_waiting = 0;
@@ -1454,7 +1454,7 @@ static void init_request_info(fcgi_request *request)
/**
* Clean up child processes upon exit
*/
void fastcgi_cleanup(int signal)
static void fastcgi_cleanup(int signal)
{
#ifdef DEBUG_FASTCGI
fprintf(stderr, "FastCGI shutdown, pid %d\n", getpid());
@@ -1468,7 +1468,7 @@ void fastcgi_cleanup(int signal)
if (parent && parent_waiting) {
exit_signal = 1;
} else {
exit(0);
_exit(0);
}
}
#else