Skip to content

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

Description

@TysonAndre

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

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions