From a12a6b2237b4d1133775e452e2a65508d4af81c0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristian=20Rodr=C3=ADguez?= Date: Tue, 19 Dec 2023 19:06:51 -0300 Subject: [PATCH] cgi: tidy up fastcgi_cleanup signal handler * 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. --- sapi/cgi/cgi_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sapi/cgi/cgi_main.c b/sapi/cgi/cgi_main.c index 695a69301982..9d7e66ce2b5b 100644 --- a/sapi/cgi/cgi_main.c +++ b/sapi/cgi/cgi_main.c @@ -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