summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_execute_API.c11
-rw-r--r--ext/pcntl/tests/async_signals_2.phpt29
-rw-r--r--tests/basic/timeout_variation_10.phpt3
-rw-r--r--tests/basic/timeout_variation_9.phpt2
4 files changed, 41 insertions, 4 deletions
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index e8b70840b7..0c3917163d 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -830,6 +830,17 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache) /
/* We must re-initialize function again */
fci_cache->function_handler = NULL;
}
+
+ /* This flag is regularly checked while running user functions, but not internal
+ * So see whether interrupt flag was set while the function was running... */
+ if (EG(vm_interrupt)) {
+ EG(vm_interrupt) = 0;
+ if (EG(timed_out)) {
+ zend_timeout();
+ } else if (zend_interrupt_function) {
+ zend_interrupt_function(EG(current_execute_data));
+ }
+ }
}
zend_vm_stack_free_call_frame(call);
diff --git a/ext/pcntl/tests/async_signals_2.phpt b/ext/pcntl/tests/async_signals_2.phpt
new file mode 100644
index 0000000000..be631bab5e
--- /dev/null
+++ b/ext/pcntl/tests/async_signals_2.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Async signals in zend_call_function
+--SKIPIF--
+<?php
+if (!extension_loaded("pcntl")) print "skip";
+if (getenv("SKIP_SLOW_TESTS")) print "skip slow test";
+?>
+--FILE--
+<?php
+
+pcntl_async_signals(1);
+pcntl_signal(SIGALRM, function($signo) {
+ throw new Exception("Alarm!");
+});
+
+pcntl_alarm(1);
+try {
+ array_map(
+ 'time_nanosleep',
+ array_fill(0, 360, 1),
+ array_fill(0, 360, 0)
+ );
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Alarm!
diff --git a/tests/basic/timeout_variation_10.phpt b/tests/basic/timeout_variation_10.phpt
index b067238db5..7680c96adf 100644
--- a/tests/basic/timeout_variation_10.phpt
+++ b/tests/basic/timeout_variation_10.phpt
@@ -5,8 +5,6 @@ Timeout within shutdown function, variation
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
if (PHP_OS_FAMILY !== "Windows") die("skip Windows only test");
?>
---XFAIL--
-Missing timeout check in call_user_function
--FILE--
<?php
@@ -19,4 +17,5 @@ register_shutdown_function("sleep", 1);
shutdown happens after here
--EXPECTF--
shutdown happens after here
+
Fatal error: Maximum execution time of 1 second exceeded in %s on line %d
diff --git a/tests/basic/timeout_variation_9.phpt b/tests/basic/timeout_variation_9.phpt
index e59ae242dc..d645ef2bbf 100644
--- a/tests/basic/timeout_variation_9.phpt
+++ b/tests/basic/timeout_variation_9.phpt
@@ -5,8 +5,6 @@ Timeout within shutdown function
if (getenv("SKIP_SLOW_TESTS")) die("skip slow test");
if (PHP_OS_FAMILY !== "Windows") die("skip Windows only test");
?>
---XFAIL--
-Missing timeout check in call_user_function
--FILE--
<?php