Closed bwoebi closed 8 years ago
How about installing the signals when the event loop starts to run because there won't ever be more than one event loop running. If we really need more than one event loop running at some point there should be a way to have a composite loop and this composite loop should handle things that cannot be handled more than once.
How about installing the signals when the event loop starts to run because there won't ever be more than one event loop running.
That's not true, that's the issue. Functions like shutdowns might require a fresh loop. So they will stack. There's still only one running at any time. But as soon as the inner loop ends, the other one will continue.
As there seems to be no further comments, may someone merge it?
👍
This needs to be undefined behavior as we do not have the possibilities in PHP (i.e. the language and functions don't give us the power) to distinguish properly whether a signal is already installed or not Also, when we try to set a handler for a signal we've already installed a signal elsewhere, the second onSignal() call will lead implementations to override the original handler (on the system level, with signal()/sigaction()) Ultimately some extensions just flat out emit a warning in that case (e.g. libev).
Thus, we cannot control what happens and hence this needs to be specified as undefined behavior.
Also see issues we encountered with https://github.com/async-interop/event-loop-test/blob/d6c299a4485e0ebb731a8d239ccaff346a3fe531/src/Test.php#L943 … Turned out we just were even unable to make this test work in a controlled way.