@@ -1338,68 +1338,26 @@ static void pcntl_signal_handler(int signo, siginfo_t *siginfo, void *context)
1338
1338
static void pcntl_signal_handler (int signo )
1339
1339
#endif
1340
1340
{
1341
- struct php_pcntl_pending_signal * psig_first = PCNTL_G (spares );
1342
- if (!psig_first ) {
1341
+ struct php_pcntl_pending_signal * psig = PCNTL_G (spares );
1342
+ if (!psig ) {
1343
1343
/* oops, too many signals for us to track, so we'll forget about this one */
1344
1344
return ;
1345
1345
}
1346
+ PCNTL_G (spares ) = psig -> next ;
1346
1347
1347
- struct php_pcntl_pending_signal * psig = NULL ;
1348
-
1349
- /* Standard signals may be merged into a single one.
1350
- * POSIX specifies that SIGCHLD has the si_pid field (https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html),
1351
- * so we'll handle the merging for that signal.
1352
- * See also: https://www.gnu.org/software/libc/manual/html_node/Merged-Signals.html */
1353
- if (signo == SIGCHLD ) {
1354
- /* Note: The first waitpid result is not necessarily the pid that was passed above!
1355
- * We therefore cannot avoid the first waitpid() call. */
1356
- int status ;
1357
- pid_t pid ;
1358
- while (true) {
1359
- do {
1360
- errno = 0 ;
1361
- /* Although Linux specifies that WNOHANG will never result in EINTR, POSIX doesn't say so:
1362
- * https://pubs.opengroup.org/onlinepubs/9699919799/functions/waitpid.html */
1363
- pid = waitpid (-1 , & status , WNOHANG | WUNTRACED );
1364
- } while (pid <= 0 && errno == EINTR );
1365
- if (pid <= 0 ) {
1366
- if (UNEXPECTED (!psig )) {
1367
- /* The child might've been consumed by another thread and will be handled there. */
1368
- return ;
1369
- }
1370
- break ;
1371
- }
1372
-
1373
- psig = psig ? psig -> next : psig_first ;
1374
- psig -> signo = signo ;
1375
-
1376
- #ifdef HAVE_STRUCT_SIGINFO_T
1377
- psig -> siginfo = * siginfo ;
1378
- psig -> siginfo .si_pid = pid ;
1379
- #endif
1380
-
1381
- if (UNEXPECTED (!psig -> next )) {
1382
- break ;
1383
- }
1384
- }
1385
- } else {
1386
- psig = psig_first ;
1387
- psig -> signo = signo ;
1348
+ psig -> signo = signo ;
1349
+ psig -> next = NULL ;
1388
1350
1389
1351
#ifdef HAVE_STRUCT_SIGINFO_T
1390
- psig -> siginfo = * siginfo ;
1352
+ psig -> siginfo = * siginfo ;
1391
1353
#endif
1392
- }
1393
-
1394
- PCNTL_G (spares ) = psig -> next ;
1395
- psig -> next = NULL ;
1396
1354
1397
1355
/* the head check is important, as the tick handler cannot atomically clear both
1398
1356
* the head and tail */
1399
1357
if (PCNTL_G (head ) && PCNTL_G (tail )) {
1400
- PCNTL_G (tail )-> next = psig_first ;
1358
+ PCNTL_G (tail )-> next = psig ;
1401
1359
} else {
1402
- PCNTL_G (head ) = psig_first ;
1360
+ PCNTL_G (head ) = psig ;
1403
1361
}
1404
1362
PCNTL_G (tail ) = psig ;
1405
1363
PCNTL_G (pending_signals ) = 1 ;
0 commit comments