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

IO.select on child process stdout, stderr does not work. #5058

Open
cyclump opened this issue Feb 22, 2018 · 1 comment
Open

IO.select on child process stdout, stderr does not work. #5058

cyclump opened this issue Feb 22, 2018 · 1 comment

Comments

@cyclump
Copy link

cyclump commented Feb 22, 2018

Environment

Ruby 2.3.3, 2.4.1, 2.5.0 for expected results
JRuby 9.0.5, 9.1.7, 9.1.16 for actual results
Windows 7 64 bit
java -version output

java version "1.8.0_121"
Java(TM) SE Runtime Environment (build 1.8.0_121-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.121-b13, mixed mode)

Other relevant info you may wish to add:

  • Installed or activated gems - None
  • Application/framework version (e.g. Rails, Sinatra) - None
  • Environment variables - None that matter. These was done under vanilla installs of Ruby and JRuby.

Expected Behavior

The attached archive contains a script called test.rb.

child_process_io_select_demo.zip

When I run test.rb under Ruby >= 2.3 I get results similar to this.

stdout is #IO:0x00000002da0668
stderr is #IO:0x00000002da05c8
No IO Available - select timeout worked
No IO Available - select timeout worked
No IO Available - select timeout worked
Read 100 from stream #IO:0x00000002da0668
Read 100 from stream #IO:0x00000002da0668
Read 100 from stream #IO:0x00000002da0668
Read 100 from stream #IO:0x00000002da0668
Read 100 from stream #IO:0x00000002da0668
Read 100 from stream #IO:0x00000002da0668
Read 100 from stream #IO:0x00000002da0668
Read 100 from stream #IO:0x00000002da0668
Read 100 from stream #IO:0x00000002da0668
Read 100 from stream #IO:0x00000002da0668
No IO Available - select timeout worked
No IO Available - select timeout worked
Read 4 from stream #IO:0x00000002da0668
Read 54 from stream #IO:0x00000002da05c8
No IO Available - select timeout worked
EAGAINWaitReadable exceptions 0
EOFError exceptions 2
total duration 7.243
avg IO.Select time 0.4003888888888889

Actual Behavior

When I run the script under the JRuby versions listed at the top I get results similar to this.

stdout is #IO:0x553a3d88
stderr is #IO:0x5891e32e
EAGAINWaitReadable exceptions 912342
EOFError exceptions 0
total duration 12.085
avg IO.Select time 4.6999918890062625e-06

It seems that select is not working (avg select function time is 0.00000469 seconds). When read_nonblock is called it raises EAGAINWaitReadable every time it is called. It is then impossible to read from the stdout after that.

@headius
Copy link
Member

headius commented Feb 23, 2018

Windows! Yes, this is expected behavior mostly due to two things:

  • Java's process API does not produce selectable streams
  • Our native process API has not been ported to Windows yet

There are other issues about this and it will be fixed soon, but resources are tight. It may be possible to improve things for the script you've provided without going all the way to getting native processes working.

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