Skip to content

Commit eb23857

Browse files
authored
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.
1 parent f359c0b commit eb23857

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

sapi/cgi/cgi_main.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ int __riscosify_control = __RISCOSIFY_STRICT_UNIX_SPECS;
9797

9898
#ifndef PHP_WIN32
9999
/* XXX this will need to change later when threaded fastcgi is implemented. shane */
100-
struct sigaction act, old_term, old_quit, old_int;
100+
static struct sigaction act, old_term, old_quit, old_int;
101101
#endif
102102

103103
static void (*php_php_import_environment_variables)(zval *array_ptr);
@@ -116,7 +116,7 @@ static int parent = 1;
116116

117117
#ifndef PHP_WIN32
118118
/* Did parent received exit signals SIG_TERM/SIG_INT/SIG_QUIT */
119-
static int exit_signal = 0;
119+
static volatile sig_atomic_t exit_signal = 0;
120120

121121
/* Is Parent waiting for children to exit */
122122
static int parent_waiting = 0;
@@ -1454,7 +1454,7 @@ static void init_request_info(fcgi_request *request)
14541454
/**
14551455
* Clean up child processes upon exit
14561456
*/
1457-
void fastcgi_cleanup(int signal)
1457+
static void fastcgi_cleanup(int signal)
14581458
{
14591459
#ifdef DEBUG_FASTCGI
14601460
fprintf(stderr, "FastCGI shutdown, pid %d\n", getpid());
@@ -1468,7 +1468,7 @@ void fastcgi_cleanup(int signal)
14681468
if (parent && parent_waiting) {
14691469
exit_signal = 1;
14701470
} else {
1471-
exit(0);
1471+
_exit(0);
14721472
}
14731473
}
14741474
#else

0 commit comments

Comments
 (0)