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

The child-process gem fails to spawn processes on Windows #4122

Closed
joankaradimov opened this issue Aug 31, 2016 · 4 comments
Closed

The child-process gem fails to spawn processes on Windows #4122

joankaradimov opened this issue Aug 31, 2016 · 4 comments
Milestone

Comments

@joankaradimov
Copy link
Contributor

Environment

jruby version: jruby 9.1.3.0 (2.3.1) 2016-08-29 a2a3b29 Java HotSpot(TM) 64-Bit Server VM 25.66-b18 on 1.8.0_66-b18 +jit [mswin32-x86_64]
OS: Windows 10
childprocess version: 0.5.9

Expected Behavior

Running:

gem 'childprocess'
require 'childprocess'
cp = ChildProcess.new('notepad.exe')
cp.start # errors

... should spawn a new process. This works on jruby 9.1.2.0

Actual Behavior

This exception is raised:

ChildProcess::Error: Unknown error (Windows says "The operation completed successfully.", but it did not.)
        from C:/dev/jruby-9.1.3.0/lib/ruby/gems/shared/gems/childprocess-0.5.9/lib/childprocess/windows/lib.rb:325:in `handle_for'
        from C:/dev/jruby-9.1.3.0/lib/ruby/gems/shared/gems/childprocess-0.5.9/lib/childprocess/jruby.rb:48:in `windows_handle_for'
        from C:/dev/jruby-9.1.3.0/lib/ruby/gems/shared/gems/childprocess-0.5.9/lib/childprocess/windows/lib.rb:306:in `handle_for'
        from C:/dev/jruby-9.1.3.0/lib/ruby/gems/shared/gems/childprocess-0.5.9/lib/childprocess/windows/process_builder.rb:137:in `std_stream_handle_for'
        from C:/dev/jruby-9.1.3.0/lib/ruby/gems/shared/gems/childprocess-0.5.9/lib/childprocess/windows/process_builder.rb:132:in `setup_io'
        from C:/dev/jruby-9.1.3.0/lib/ruby/gems/shared/gems/childprocess-0.5.9/lib/childprocess/windows/process_builder.rb:32:in `start'
        from C:/dev/jruby-9.1.3.0/lib/ruby/gems/shared/gems/childprocess-0.5.9/lib/childprocess/windows/process.rb:69:in `launch_process'
        from C:/dev/jruby-9.1.3.0/lib/ruby/gems/shared/gems/childprocess-0.5.9/lib/childprocess/abstract_process.rb:82:in `start'
        from (irb):4:in `<eval>'
        from org/jruby/RubyKernel.java:994:in `eval'
        from org/jruby/RubyKernel.java:1295:in `loop'
        from org/jruby/RubyKernel.java:1114:in `catch'
        from org/jruby/RubyKernel.java:1114:in `catch'
        from C:/dev/jruby-9.1.3.0/bin/jirb:13:in `<main>'

Notes

I noticed that issue #2598 has an identical error message.

@enebo enebo added this to the JRuby 9.1.4.0 milestone Sep 1, 2016
@enebo
Copy link
Member

enebo commented Sep 1, 2016

Running this I can see we bomb out trying to get the handle for stdin. Something changed since 9.1.2.0

@headius
Copy link
Member

headius commented Sep 1, 2016

Tracked it down to the fix for Drip in #2690 (7e024a7) which modified stdio behavior to report actual fileno rather than always the 0, 1, 2 of typical in, out, err. This works fine on platforms where we can use native IO, but our Windows IO logic is not native yet. In addition, when running without native calls enabled, we still need to gracefully fall back and report 0, 1, 2.

I have a patch in progress.

@headius headius closed this as completed in 1a977d5 Sep 1, 2016
@headius
Copy link
Member

headius commented Sep 1, 2016

Have fix, need tests. Not sure the best way to do this beyond just verifying that in a "simple" JRuby process, stdio has sane filenos.

@headius
Copy link
Member

headius commented Sep 1, 2016

All good!

enebo pushed a commit that referenced this issue Sep 1, 2016
This code was originally removed in 7e024a7
to fix #2690, but childprocess was no longer able to launch
a subprocess (#4122). Until Windows has native, we need this code
in place...and may always need it for non-native setups, to keep
stdio fileno sane.

Fixes #4122.
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

3 participants