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

popen3 block execution #1920

Closed
akostadinov opened this issue Aug 26, 2014 · 1 comment
Closed

popen3 block execution #1920

akostadinov opened this issue Aug 26, 2014 · 1 comment
Milestone

Comments

@akostadinov
Copy link

[2] pry(main)> Open3.popen3("pwd", :chdir=>"/tmp") {|i,o,e,t|
[2] pry(main)*   puts "ok"  
[2] pry(main)* }  
ok
Java::JavaLang::ClassCastException: org.jruby.util.ShellLauncher$POpenProcess cannot be cast to org.jruby.util.io.POSIXProcess
from org.jruby.RubyIO.rbIoClose(RubyIO.java:1802)

I'm using:
jruby 9000.dev-SNAPSHOT (2.1.2) 2014-08-06 22bf660 OpenJDK 64-Bit Server VM 24.65-b04 on 1.7.0_65-mockbuild_2014_07_17_14_16-b00 [linux-amd64]

btw in non-block syntax it seems to be working without errors:

[4] pry(main)> Open3.popen3("pwd", :chdir=>"/")
=> [#<IO:0x5d80186a>,
 #<IO:0x7f26ca93>,
 #<IO:0x4bbdba1c>,
 #<Process::WaitThread:0x1505ab1d dead>]

UPDATE: another issue I see is capture2. It must be returning status according to ruby docs but it apears to be returning a process id:

[16] pry(main)> o,s = Open3.capture2('echo asd', :chdir=>"/tmp")
=> ["asd\n", 5262]

This is MRI output:

[3] pry(main)> o,s = Open3.capture2('pwd', :chdir=>"/tmp")
=> ["/tmp\n", #<Process::Status: pid 5401 exit 0>]
@kares
Copy link
Member

kares commented May 23, 2017

long-time-since but this seem to be doing well on JRuby 9.1.9.0 :

jruby-9.1.9.0 :001 > require 'open3'
 => true 
jruby-9.1.9.0 :002 > o,s = Open3.capture2('echo asd', :chdir=>"/tmp")
 => ["asd\n", #<Process::Status: pid 2932 exit 0>] 
jruby-9.1.9.0 :003 > Open3.popen3("pwd", :chdir=>"/tmp") { |i,o,e,t| puts "ok"; }
ok
 => nil 

@kares kares closed this as completed May 23, 2017
@kares kares added this to the JRuby 9.1.9.0 milestone May 23, 2017
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