@@ -1048,68 +1048,26 @@ static void pcntl_signal_handler(int signo, siginfo_t *siginfo, void *context)
1048
1048
static void pcntl_signal_handler (int signo )
1049
1049
#endif
1050
1050
{
1051
- struct php_pcntl_pending_signal * psig_first = PCNTL_G (spares );
1052
- if (!psig_first ) {
1051
+ struct php_pcntl_pending_signal * psig = PCNTL_G (spares );
1052
+ if (!psig ) {
1053
1053
/* oops, too many signals for us to track, so we'll forget about this one */
1054
1054
return ;
1055
1055
}
1056
+ PCNTL_G (spares ) = psig -> next ;
1056
1057
1057
- struct php_pcntl_pending_signal * psig = NULL ;
1058
-
1059
- /* Standard signals may be merged into a single one.
1060
- * POSIX specifies that SIGCHLD has the si_pid field (https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html),
1061
- * so we'll handle the merging for that signal.
1062
- * See also: https://www.gnu.org/software/libc/manual/html_node/Merged-Signals.html */
1063
- if (signo == SIGCHLD ) {
1064
- /* Note: The first waitpid result is not necessarily the pid that was passed above!
1065
- * We therefore cannot avoid the first waitpid() call. */
1066
- int status ;
1067
- pid_t pid ;
1068
- while (true) {
1069
- do {
1070
- errno = 0 ;
1071
- /* Although Linux specifies that WNOHANG will never result in EINTR, POSIX doesn't say so:
1072
- * https://pubs.opengroup.org/onlinepubs/9699919799/functions/waitpid.html */
1073
- pid = waitpid (-1 , & status , WNOHANG | WUNTRACED );
1074
- } while (pid <= 0 && errno == EINTR );
1075
- if (pid <= 0 ) {
1076
- if (UNEXPECTED (!psig )) {
1077
- /* The child might've been consumed by another thread and will be handled there. */
1078
- return ;
1079
- }
1080
- break ;
1081
- }
1082
-
1083
- psig = psig ? psig -> next : psig_first ;
1084
- psig -> signo = signo ;
1085
-
1086
- #ifdef HAVE_STRUCT_SIGINFO_T
1087
- psig -> siginfo = * siginfo ;
1088
- psig -> siginfo .si_pid = pid ;
1089
- #endif
1090
-
1091
- if (UNEXPECTED (!psig -> next )) {
1092
- break ;
1093
- }
1094
- }
1095
- } else {
1096
- psig = psig_first ;
1097
- psig -> signo = signo ;
1058
+ psig -> signo = signo ;
1059
+ psig -> next = NULL ;
1098
1060
1099
1061
#ifdef HAVE_STRUCT_SIGINFO_T
1100
- psig -> siginfo = * siginfo ;
1062
+ psig -> siginfo = * siginfo ;
1101
1063
#endif
1102
- }
1103
-
1104
- PCNTL_G (spares ) = psig -> next ;
1105
- psig -> next = NULL ;
1106
1064
1107
1065
/* the head check is important, as the tick handler cannot atomically clear both
1108
1066
* the head and tail */
1109
1067
if (PCNTL_G (head ) && PCNTL_G (tail )) {
1110
- PCNTL_G (tail )-> next = psig_first ;
1068
+ PCNTL_G (tail )-> next = psig ;
1111
1069
} else {
1112
- PCNTL_G (head ) = psig_first ;
1070
+ PCNTL_G (head ) = psig ;
1113
1071
}
1114
1072
PCNTL_G (tail ) = psig ;
1115
1073
PCNTL_G (pending_signals ) = 1 ;
0 commit comments