Don't use ext-readline handler on Mac to fix CR/LF issues on Mac only - #73
Conversation
mkopinsky
commented
Jul 3, 2018
This is causing some weird issues. When I exit (by hitting Ctrl-D), it outputs I will try to poke at this a bit later and open a PR (it makes more sense for the guy with a Mac to poke at), but wanted to bring to your attention in case you already know what the issue or fix is. |
clue
commented
Jul 3, 2018
@mkopinsky Thank you for giving this a try and reporting back! I agree and any input would be very much appreciated, as I don't have a Mac to test against 👍 I can not reproduce any issues on my Ubuntu system, maybe we can also come up with a way to test this specific behavior? |
mkopinsky
commented
Jul 3, 2018
I can try to write a unit test as part of the PR. Seems that travis has a Mac OS environment so we can have that test run on Mac-only. |
clue
commented
Jul 3, 2018
Improving the test suite in this regard would be much appreciated! That being said, our latest tries with Travis' Mac builds weren't all that good (reactphp/stream#120 and others). |
I haven't quite been able to figure it out, but I wanted to share what I'm seeing.
If I comment out the fclose on |
clue
commented
Jul 5, 2018
Thank you for looking into this! I currently fail to see how the stream resource could be closed before invoking the The following is a gist of what the Stdio class does, so maybe this helps reproducing this: <?phpuseReact\Stream\ReadableResourceStream;
useReact\EventLoop\Factory;
require__DIR__ . '/../vendor/autoload.php';
$loop = Factory::create();
$stdin = newReadableResourceStream(STDIN, $loop);
$old = shell_exec('stty -g');
shell_exec('stty -icanon -echo');
$stdin->on('data', function ($chunk) use ($stdin) {
echowordwrap(bin2hex($chunk), 2, '', true) . PHP_EOL;
if (strpos($chunk, "\x04") !== false) {
echo'[EOF]';
$stdin->close();
}
});
$stdin->on('close', function () use ($old) {
echo'[closed]';
shell_exec('stty ' . $old);
});
$loop->run(); |
mkopinsky
commented
Jul 5, 2018
With that mini script, it worked fine. |
clue
commented
Jul 6, 2018
That's strange. Can you try patching Line 228 in a62268d restoreTtyMode() at the start of the method? |
clue
commented
Jul 7, 2018
@mkopinsky I think I've been able to track this down and managed to reproduce this on any system without |
Resolves / closes#66
Effectively reverts #63 on Mac