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

Avoid warning when catching signal with pcntl_signal() #297

Closed
wants to merge 8 commits into from

Conversation

Divi
Copy link

@Divi Divi commented Apr 19, 2014

Creating a temporary error handler when selecting/accepting a stream to avoid warning messages, caused by catching a signal with function pcntl_signal().

See issue : #296

@Divi
Copy link
Author

Divi commented Apr 19, 2014

Great idea, but they use the prefix @, and I wanted to avoid it due to low performance of this trick.

@romainneutron
Copy link
Member

I'm curious about what low performance you're speaking. Symfony's code bypasses the error and check if it was a interrupted system call only if stream_select returned false whereas your implementation switches the error handler twice for every call. It's definitely not a such low performance trick :)

@Divi
Copy link
Author

Divi commented Apr 19, 2014

I was not saying my fix is more efficient than another. I just tried to avoid the @ trigger.
Moreover, I didn't know about the false return statement on error of the function stream_select, so the Symfony's fix is clearly better.
I can't fix it this PR today. I'll do the change tomorrow :)

@romainneutron
Copy link
Member

no worries. Avoid the use of @ when it's about dicarding errors when they should not be, but in this case we just filter errors that could be safely discarded.
thanks for your work

@Divi
Copy link
Author

Divi commented Apr 21, 2014

Fixes are available as @romainneutron advised. I saw a bug only after some commit sorry.

@mathielen
Copy link

Works like a charm. When does it get merged back?

$lastError = error_get_last();

// stream_select returns false when the `select` system call is interrupted by an incoming signal
return isset($lastError['message']) && false !== stripos($lastError['message'], 'interrupted system call');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some tests would be much appreciated 👍

Also IIRC, the error messages take the user's LOCALE into account and might be translated to another language. If so, how should we match those?

@Divi
Copy link
Author

Divi commented May 6, 2014

@clue I've my locale set to french and the message is still in english.

@kingcrunch
Copy link

When is it planned to get merged?

@POPSuL
Copy link

POPSuL commented Nov 14, 2014

Why not merged yet?

@cboden
Copy link
Member

cboden commented Nov 16, 2014

This is now a read-only repo made up of components loaded from composer. Merge requests need to made against the event-loop. In addition, I wouldn't want to include @stream_select in the source code. stream_select is the core of the EventLoop and error suppression is detrimental to performance.

@mkrauser
Copy link

mkrauser commented Dec 3, 2014

Right, supressing errors is bad for performance, especially inside the event-loop. I wouldn't put this into the core either. But there should be a way out for users. Maybe a special subclass or at least a hint in the docs.

Regarding the check for the return-value: this should definitely be merged. If the stream_select-call fails, you should not rely on the references.

@HarasimowiczKamil
Copy link

Try use declare(ticks=1); on top in root file. Then you can catch signals without errors/warnings.

@frodeborli
Copy link

I am pretty sure this will slow down your app considerably.

On Wed, Jun 10, 2015 at 7:51 AM, Kamil Harasimowicz <
notifications@github.com> wrote:

Try use declare(ticks=1); on top in root file. Then you can catch signals
without errors/warnings.


Reply to this email directly or view it on GitHub
#297 (comment).

@HarasimowiczKamil
Copy link

Probably yes but in many cases it might not be as critical, and will work without problems.

@clue
Copy link
Member

clue commented Sep 19, 2015

This PR seems like a good starting point, thanks @Divi!

This PR has been WIP for quite some time now and things have changed considerably since then :-)

React now consists of individual components that are maintained individually. Supporting signal handling is now related to the react/event-loop component.

Somebody has already filed a ticket reactphp/event-loop#8 to keep track of this, so I suppose it makes sense to focus our signal handling related efforts on this component.

@clue clue closed this Sep 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants