Ruby Io.popen stucks和cmd未关闭

Ruby Io.popen stucks和cmd未关闭,ruby,Ruby,我使用这行代码从方法send\u crs调用方法send\u csr1: send_csr1(pipe.read,@username,@password) 问题是通常会执行下一行代码: pipe.close_write 但不知何故,它不会导致cmd从未关闭。当我手动关闭它时,会出现以下错误: in `read': Interrupt from stack.rb:49:in `block in send_csr' from stack.rb:45:in `popen'

我使用这行代码从方法
send\u crs
调用方法
send\u csr1

send_csr1(pipe.read,@username,@password)  
问题是通常会执行下一行代码:

pipe.close_write
但不知何故,它不会导致cmd从未关闭。当我手动关闭它时,会出现以下错误:

  in `read': Interrupt
    from stack.rb:49:in `block in send_csr'
    from stack.rb:45:in `popen'
    from stack.rb:45:in `send_csr'
    from stack.rb:88:in `block in <main>'
    from stack.rb:87:in `each'
    from stack.rb:87:in `<main>'

可能pipe.read正在阻塞,等待它读取“所有输入”,请尝试使用recv或其他方法,如get[?]没有mehod recv,但基本上这是一个好主意!
def send_csr
 IO.popen('cmd', 'r+') do |pipe|
 pipe.puts('cd C:/OpenSSL/bin')
 pipe.puts('openssl.exe')
 pipe.puts("req  -config c:/OpenSSL/openssl.cnf -in  #{@csr}")
 send_csr1(pipe.read,@username,@password)   
 pipe.close_write
end
end

def send_csr1(text,user,password)
 @conn.basic_auth(user,password)
 @res = @conn.get do |request|  
 request.url "csr"
 request.headers['Content-Type'] = 'text/plain'
 request.body = "#{text}"
end
end