[#84867] [Ruby trunk Bug#14357] thread_safe tests suite segfaults — v.ondruch@...

Issue #14357 has been reported by vo.x (Vit Ondruch).

11 messages 2018/01/15

[#84980] [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — hsbt@...

Issue #13618 has been updated by hsbt (Hiroshi SHIBATA).

10 messages 2018/01/23
[#85012] Re: [Ruby trunk Feature#13618][Assigned] [PATCH] auto fiber schedule for rb_wait_for_single_fd and rb_waitpid — Eric Wong <normalperson@...> 2018/01/23

hsbt@ruby-lang.org wrote:

[ruby-core:84632] [Ruby trunk Bug#14198] Error forwarding standard input to subprocess

From: betabandido@...
Date: 2018-01-04 18:26:34 UTC
List: ruby-core #84632
Issue #14198 has been updated by betabandido (Victor Jimenez).


Thanks for the suggestions. 

The following code snippet based on `IO.popen` seems to work. It executes a command, and it returns its output as an array containing the output lines. Optionally, the output is written to stdout too.

~~~ ruby
def run(cmd, directory: Dir.pwd, print_output: true)
  out = IO.popen(cmd, err: %i[child out], chdir: directory) do |io|
    begin
      out = ''
      loop do
        chunk = io.readpartial(4096)
        print chunk if print_output
        out += chunk
      end
    rescue EOFError; end
    out
  end

  $?.exitstatus.zero? || (raise "Error running command #{cmd}")

  out.split("\n")
     .map { |line| line.tr("\r\n", '') }
end
~~~

I am not sure whether there is an easier way to accomplish this, but this seems good enough.

----------------------------------------
Bug #14198: Error forwarding standard input to subprocess
https://bugs.ruby-lang.org/issues/14198#change-69205

* Author: betabandido (Victor Jimenez)
* Status: Feedback
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: ruby 2.4.2p198 (2017-09-14 revision 59899) [x64-mingw32]
* Backport: 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
I am developing a wrapper for Terraform (https://www.terraform.io/), which at some point during its execution, it may request user input. So, my application must forward everything typed on its stdin to the subprocess' stdin. The following solution works on Linux, but on Windows the subprocess (Terraform) seems to never receive the input.

A similar approach works for wrappers implemented in Python or Go, so I believe this may actually be a bug in Ruby itself.

The file test.rb contains the code to reproduce the issue. First, Terraform is downloaded in the working directory. Then, popen3 is used to run Terraform.


---Files--------------------------------
Gemfile (46 Bytes)
test.rb (1.27 KB)


-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>

In This Thread

Prev Next