@@ -1338,15 +1338,13 @@ 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 ;
1342
-
1343
- psig = PCNTL_G (spares );
1344
- if (!psig ) {
1341
+ struct php_pcntl_pending_signal * psig_first = PCNTL_G (spares );
1342
+ if (!psig_first ) {
1345
1343
/* oops, too many signals for us to track, so we'll forget about this one */
1346
1344
return ;
1347
1345
}
1348
1346
1349
- struct php_pcntl_pending_signal * psig_first = psig ;
1347
+ struct php_pcntl_pending_signal * psig = NULL ;
1350
1348
1351
1349
/* Standard signals may be merged into a single one.
1352
1350
* POSIX specifies that SIGCHLD has the si_pid field (https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/signal.h.html),
@@ -1365,28 +1363,27 @@ static void pcntl_signal_handler(int signo)
1365
1363
pid = waitpid (WAIT_ANY , & status , WNOHANG | WUNTRACED );
1366
1364
} while (pid <= 0 && errno == EINTR );
1367
1365
if (pid <= 0 ) {
1368
- if (UNEXPECTED ( psig == psig_first ) ) {
1369
- /* Don't handle multiple, revert back to the single signal handling . */
1370
- goto single_signal ;
1366
+ if (! psig ) {
1367
+ /* The child might've been consumed by another thread and will be handled there . */
1368
+ return ;
1371
1369
}
1372
1370
break ;
1373
1371
}
1374
1372
1373
+ psig = psig ? psig -> next : psig_first ;
1375
1374
psig -> signo = signo ;
1376
1375
1377
1376
#ifdef HAVE_STRUCT_SIGINFO_T
1378
1377
psig -> siginfo = * siginfo ;
1379
1378
psig -> siginfo .si_pid = pid ;
1380
1379
#endif
1381
1380
1382
- if (EXPECTED (psig -> next )) {
1383
- psig = psig -> next ;
1384
- } else {
1381
+ if (UNEXPECTED (!psig -> next )) {
1385
1382
break ;
1386
1383
}
1387
1384
}
1388
1385
} else {
1389
- single_signal : ;
1386
+ psig = psig_first ;
1390
1387
psig -> signo = signo ;
1391
1388
1392
1389
#ifdef HAVE_STRUCT_SIGINFO_T
0 commit comments