Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for pcntl_async_signals in NativeDriver #264

Closed
Ekstazi opened this issue Feb 25, 2019 · 1 comment
Closed

Support for pcntl_async_signals in NativeDriver #264

Ekstazi opened this issue Feb 25, 2019 · 1 comment

Comments

@Ekstazi
Copy link

Ekstazi commented Feb 25, 2019

Php 7.1 introduce new way to handle signals.

If pcntl_async_signals is set to true then all signals will be processed async and immediate.

But if context of execution is not in NativeDriver (in synchronous code) then this error happens:

^CPHP Warning:  Invalid callback Amp\Loop\NativeDriver::handleSignal, cannot access private method Amp\Loop\NativeDriver::handleSignal() in /app/test.php on line 9
PHP Stack trace:
PHP   1. {main}() /app/test.php:0
PHP   2. Amp\Loop::run($callback = *uninitialized*) /app/test.php:11
PHP   3. Amp\Loop\NativeDriver->run() /app/vendor/amphp/amp/lib/Loop.php:84
PHP   4. Amp\Loop\NativeDriver->tick() /app/vendor/amphp/amp/lib/Loop/Driver.php:72
PHP   5. Amp\Loop\NativeDriver->dispatch($blocking = *uninitialized*) /app/vendor/amphp/amp/lib/Loop/Driver.php:134
PHP   6. {closure:/app/test.php:8-10}(*uninitialized*, *uninitialized*) /app/vendor/amphp/amp/lib/Loop/NativeDriver.php:130

Example code to reproduce error:

<?php
require __DIR__.'/vendor/autoload.php';

pcntl_async_signals(true);
\Amp\Loop::onSignal(SIGINT, function (){
	echo "sigterm\n";
});
\Amp\Loop::repeat(100, function(){
	sleep(1);
});
\Amp\Loop::run();

I understand that amp not support sync code and this error will be only in rare cases.

P.S.: sorry for bad english.

@Ekstazi
Copy link
Author

Ekstazi commented Feb 26, 2019

May be need to enable async signals by default ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant