Module: PryRemote

Defined in:
lib/pry-remote.rb

Defined Under Namespace

Classes: CLI, Client, IOUndumpedProxy, InputProxy, Server

Constant Summary collapse

DefaultHost =
"127.0.0.1"
DefaultPort =
9876
System =

Ensure that system (shell command) output is redirected for remote session.

proc do |output, cmd, _|
  status = nil
  Open3.popen3 cmd do |stdin, stdout, stderr, wait_thr|
    stdin.close # Send EOF to the process

    until stdout.eof? and stderr.eof?
      if res = IO.select([stdout, stderr])
        res[0].each do |io|
          next if io.eof?
          output.write io.read_nonblock(1024)
        end
      end
    end

    status = wait_thr.value
  end

  unless status.success?
    output.puts "Error while executing command: #{cmd}"
  end
end