@@ -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,25 @@ 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 ;
1371
- }
1366
+ /* There must've been at least one iteration so that psig is initialized. */
1367
+ ZEND_ASSERT (psig != NULL );
1372
1368
break ;
1373
1369
}
1374
1370
1371
+ psig = psig ? psig -> next : psig_first ;
1375
1372
psig -> signo = signo ;
1376
1373
1377
1374
#ifdef HAVE_STRUCT_SIGINFO_T
1378
1375
psig -> siginfo = * siginfo ;
1379
1376
psig -> siginfo .si_pid = pid ;
1380
1377
#endif
1381
1378
1382
- if (EXPECTED (psig -> next )) {
1383
- psig = psig -> next ;
1384
- } else {
1379
+ if (UNEXPECTED (!psig -> next )) {
1385
1380
break ;
1386
1381
}
1387
1382
}
1388
1383
} else {
1389
- single_signal : ;
1384
+ psig = psig_first ;
1390
1385
psig -> signo = signo ;
1391
1386
1392
1387
#ifdef HAVE_STRUCT_SIGINFO_T
0 commit comments