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

Redirect to IO.pipe on Windows causes inability to start a process #161

Closed
barancev opened this issue Oct 3, 2019 · 6 comments
Closed

Comments

@barancev
Copy link

barancev commented Oct 3, 2019

JRuby 9.2.8.0, Windows 10, Oracle Java 1.8.0_211

Reproduction sample:

r, w = IO.pipe
proc = ChildProcess.build('notepad.exe')
#proc.io.inherit!
proc.io.stdout = proc.io.stderr = w
proc.leader = true
proc.start
proc.wait
w.close

does not start Notepad and fails with this log:

C:\tools\jruby-9.2.8.0\bin\jruby.exe C:/devel/try-something/rb/sample.rb
ChildProcess::Error: Unknown error (Windows says "The operation completed successfully.", but it did not.)
             handle_for at C:/tools/jruby-9.2.8.0/lib/ruby/gems/shared/gems/childprocess-3.0.0/lib/childprocess/windows/lib.rb:326
     windows_handle_for at C:/tools/jruby-9.2.8.0/lib/ruby/gems/shared/gems/childprocess-3.0.0/lib/childprocess/jruby.rb:48
             handle_for at C:/tools/jruby-9.2.8.0/lib/ruby/gems/shared/gems/childprocess-3.0.0/lib/childprocess/windows/lib.rb:307
  std_stream_handle_for at C:/tools/jruby-9.2.8.0/lib/ruby/gems/shared/gems/childprocess-3.0.0/lib/childprocess/windows/process_builder.rb:141
               setup_io at C:/tools/jruby-9.2.8.0/lib/ruby/gems/shared/gems/childprocess-3.0.0/lib/childprocess/windows/process_builder.rb:113
                  start at C:/tools/jruby-9.2.8.0/lib/ruby/gems/shared/gems/childprocess-3.0.0/lib/childprocess/windows/process_builder.rb:32
         launch_process at C:/tools/jruby-9.2.8.0/lib/ruby/gems/shared/gems/childprocess-3.0.0/lib/childprocess/windows/process.rb:70
                  start at C:/tools/jruby-9.2.8.0/lib/ruby/gems/shared/gems/childprocess-3.0.0/lib/childprocess/abstract_process.rb:81
                 <main> at C:/devel/try-something/rb/sample.rb:12

If I uncomment proc.io.inherit! instead of redirecting to pipes everything works like a charm.

barancev added a commit to SeleniumHQ/selenium that referenced this issue Oct 3, 2019
Backticks don't allow streaming the logs in runtime,
so this code should be rewritten to childprocess
when enkessler/childprocess#161 is fixed.
@sds sds added the help wanted label Oct 5, 2019
@sds
Copy link
Collaborator

sds commented Oct 5, 2019

Hey @barancev, thanks for the report.

What you are trying to do is pretty straightforward, but this particular combination of tools (JRuby + Windows) is a little off the beaten path. Perhaps there are limitations with JRuby's implementation of IO.pipe that you're hitting in this context which don't play well with the process builder.

Would appreciate help from interested folks in investigating this particular issue. Thanks!

@barancev
Copy link
Author

barancev commented Oct 6, 2019

Is it better to report this to the JRuby team?

@sds
Copy link
Collaborator

sds commented Oct 8, 2019

I would potentially open a bug with the JRuby team if you are unable to reproduce this bug on Windows with vanilla MRI Ruby.

The issue here is that we have code to use Windows-specific logic when running in JRuby on Windows, and I'm not sure how often this logic is exercised. The JRuby team may come back to say that it's an issue with the implementation.

If, however, you are able to get this to work with vanilla Ruby and not JRuby, that may suggest an issue with JRuby itself. Appreciate your help in investigating.

@sds
Copy link
Collaborator

sds commented Mar 1, 2020

Closing as there does not appear to be an effort to address. Happy to merge a pull request fixing the issue, if it is indeed specific to childprocess. Thanks!

@sds sds closed this as completed Mar 1, 2020
@barancev
Copy link
Author

barancev commented Mar 1, 2020

Sorry for silence, I've implemented a workaround and forgot about this issue...
Yes, it works with vanilla Ruby, so I'll report this issue to JRuby.

@barancev
Copy link
Author

barancev commented Mar 1, 2020

Here it is: jruby/jruby#6102

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants