lib/vx/lib/shell/process.rb in vx-lib-shell-0.1.2 vs lib/vx/lib/shell/process.rb in vx-lib-shell-0.1.3

- old
+ new

@@ -16,15 +16,11 @@ select_timeout = options.delete(:pool_interval) || Shell.pool_interval timeout = Shell::Timeout.new options.delete(:timeout) read_timeout = Shell::ReadTimeout.new options.delete(:read_timeout) prefix = "/usr/bin/env - TERM=ansi USER=$USER HOME=#{home} SHELL=/bin/bash /bin/bash -l" - if command - command = "#{prefix} -c #{Shellwords.escape command}" - else - command = prefix - end + command = "#{prefix} -c #{Shellwords.escape command}" status = spawn_command_internal(command, options) do |r| read_loop r, timeout, read_timeout, select_timeout, &block end @@ -33,39 +29,33 @@ private def request_pipes(options) m,s = PTY.open - r1,w1 = IO.pipe s.raw! # disable newline conversion. m.sync = true s.sync = true - [m, s, r1, w1] + [m, s] end def spawn_command_internal(command, options) - r1, w1, r2, w2 = request_pipes(options) + r1, w1 = request_pipes(options) - pid = ::Process.spawn(command, in: r2, out: w1, err: w1) + pid = ::Process.spawn(command, out: w1, err: w1) begin - if i = options[:stdin] - IO.copy_stream i, w2 - end - w2.close w1.close yield r1 rescue Errno::EIO end ::Process.kill 'KILL', pid _, status = ::Process.wait2(pid) r1.close - r2.close status end def compute_exit_code(command, status, timeout, read_timeout)