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

Could not run example in documentation due to error on MacOS #111

Open
scovit opened this issue Nov 20, 2019 · 9 comments
Open

Could not run example in documentation due to error on MacOS #111

scovit opened this issue Nov 20, 2019 · 9 comments

Comments

@scovit
Copy link

scovit commented Nov 20, 2019

  • MacOS Mojave
  • rakudo installed through homebrew
  • zef installed from github
  • cro installed through zef

Then,

  • /usr/local/Cellar/rakudo/2019.07.1/share/perl6/site/bin/cro stub http hello hello
  • /usr/local/Cellar/rakudo/2019.07.1/share/perl6/site/bin/cro run

Then open a web browser, http://localhost:20000

The page does not show, on the shell the following error:

⚠ hello Cannot flush handle: Failed to flush filehandle: Operation not supported
⚠ hello in block at /usr/local/Cellar/rakudo/2019.07.1/share/perl6/site/sources/794E18F5F4F80DEE905DE049F8655401F940C814 (Cro::HTTP::Log::File) line 28
⚠ hello in block at /usr/local/Cellar/rakudo/2019.07.1/share/perl6/site/sources/D69ADAA9BE77DD33B9702EA1BCD4D35E6379EA88 (Cro::HTTP::Internal) line 45
⚠ hello in block at /usr/local/Cellar/rakudo/2019.07.1/share/perl6/site/sources/9A69BC70F2D8C7BD950C926E19009FF093ED8524 (Cro::HTTP::Router) line 232
⚠ hello

@jnthn
Copy link
Member

jnthn commented Nov 20, 2019

Does perl6 -e '$*OUT.flush' produce the same error?

@scovit
Copy link
Author

scovit commented Nov 20, 2019

Negative: it does not produce any error

@jnthn
Copy link
Member

jnthn commented Nov 20, 2019

Hm, OK. What about if it's $*ERR? Also, what if it's:

perl6 -e 'react { my $p = Proc::Async.new("perl6", "-e", "\$*OUT.flush"); whenever $p.stdout { }; whenever $p.start { } }'

@scovit
Copy link
Author

scovit commented Nov 20, 2019

Good golf!

$ perl6 -e 'react { my $p = Proc::Async.new("perl6", "-e", "$*OUT.flush"); whenever $p.stdout { }; whenever $p.start { } }'

Cannot flush handle: Failed to flush filehandle: Operation not supported
in block at -e line 1

@scovit
Copy link
Author

scovit commented Nov 20, 2019

$*ERR is not a problem

$ perl6 -e '$*OUT.flush' | cat
Cannot flush handle: Failed to flush filehandle: Operation not supported
in block at -e line 1

@scovit
Copy link
Author

scovit commented Nov 20, 2019

Seems like a moarvm bug to me.

Since flush is implemented as fsync in moarvm, but..

$ perl6 -e 'use NativeCall; sub fsync(int32 --> int32) is native { }; say fsync(1)' | cat
returns -1.

which is right. Since pipes are not synchronous.

@jnthn
Copy link
Member

jnthn commented Nov 20, 2019

Hm, though it seems to work out on various platforms. I wonder what it should be using...

@scovit
Copy link
Author

scovit commented Nov 20, 2019

C fflush is a no-op on pipes.

I suspect that the linux kernel fsync on pipes is also a no-op, on Mac (and possibly freebsd) it returns errors.

@scovit
Copy link
Author

scovit commented Nov 20, 2019

Sorry I cannot help you in deciding what it should be. I am not enough a POSIX expert

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