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

stream_select() can emit a notice if pcntl_signal handler is set up by a caller #63

Open
TysonAndre opened this issue Oct 13, 2018 · 1 comment

Comments

@TysonAndre
Copy link
Contributor

Observed: Sabre emits a notice.
Desired: Prevent that notice, or add a configurable way for applications using sabre\event to suppress that notice

Context: This was seen in an application calling pcntl_signal() to listen for signals, then calling pcntl_fork() to create child processes (it would get signalled from within the sabre event loop)

reactphp/reactphp#296 mentions a similar issue.
See the note in https://secure.php.net/manual/en/function.stream-select.php#refsect1-function.stream-select-returnvalues

This happens in 5.0.3, probably also in master: https://github.com/sabre-io/event/blob/5.0.3/lib/Loop/Loop.php#L305

The approach taken by reactphp looks like it was to call set_error_handler before the stream operation (e.g. stream_select()), and call restore_error_handler immediately after (and check if the error was caused by pcntl in that handler)

/path/to/vendor/sabre/event/lib/Loop/Loop.php:305 [2] stream_select(): unable to select [4]: Interrupted system call (max_fd=0)

#0  my_custom_error_handler()
#1  stream_select() called at [/path/to/vendor/sabre/event/lib/Loop/Loop.php:305]
#2  Sabre\Event\Loop\Loop->runStreams() called at [/path/to/vendor/sabre/event/lib/Loop/Loop.php:233]
#3  Sabre\Event\Loop\Loop->tick() called at [/path/to/vendor/sabre/event/lib/Loop/Loop.php:194]
#4  Sabre\Event\Loop\Loop->run() called at [/path/to/vendor/sabre/event/lib/Loop/functions.php:122]
#5  Sabre\Event\Loop\run() called at ...

I can work around this by changing my_custom_error_handler

@staabm
Copy link
Member

staabm commented Oct 15, 2018

Thx for reporting.

Do you have some simplified steps to reproduce?
At best a failling unit test?

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

No branches or pull requests

2 participants