Skip to content

Commit 7c2ce26

Browse files
committed
call previous signal handler
1 parent 9213563 commit 7c2ce26

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

Zend/zend.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,8 @@ static void zend_timer_create() /* {{{ */
843843
# ifdef TIMER_DEBUG
844844
fprintf(stderr, "Timer %#jx created on thread %d\n", (uintmax_t) EG(timer), sev.sigev_notify_thread_id);
845845
# endif
846+
847+
sigaction(sev.sigev_signo, NULL, &EG(oldact));
846848
}
847849
/* }}} */
848850
# endif

Zend/zend_execute_API.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,9 +1334,16 @@ static void zend_timeout_handler(int dummy, siginfo_t *si, void *uc) /* {{{ */
13341334
{
13351335
if (si->si_value.sival_ptr != &EG(timer)) {
13361336
#ifdef TIMER_DEBUG
1337-
fprintf(stderr, "ignoring timeout signal SIGIO received on thread %d\n", (pid_t) syscall(SYS_gettid));
1337+
fprintf(stderr, "Executing previous handler (if set) for unexpected signal SIGIO received on thread %d\n", (pid_t) syscall(SYS_gettid));
13381338
#endif
13391339

1340+
if (EG(oldact).sa_sigaction) {
1341+
EG(oldact).sa_sigaction(dummy, si, uc);
1342+
1343+
return;
1344+
}
1345+
if (EG(oldact).sa_handler) EG(oldact).sa_handler(dummy);
1346+
13401347
return;
13411348
}
13421349
# else

Zend/zend_globals.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <setjmp.h>
2525
#ifdef ZEND_TIMER
2626
#include <time.h>
27+
#include <signal.h>
2728
#endif
2829

2930
#include "zend_globals_macros.h"
@@ -271,6 +272,7 @@ struct _zend_executor_globals {
271272

272273
#ifndef ZEND_TIMER
273274
timer_t timer;
275+
struct sigaction oldact;
274276
#endif
275277

276278
void *reserved[ZEND_MAX_RESERVED_RESOURCES];

0 commit comments

Comments
 (0)