Module: Ansible::SafePty

Defined in:
lib/ansible/safe_pty.rb

Overview

Wrapper for PTY pseudo-terminal

Class Method Summary collapse

Class Method Details

.spawn(command) ⇒ Integer

Spawns process for command

Parameters:

  • command (String)

    command

Returns:

  • (Integer)

    exit status



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/ansible/safe_pty.rb', line 8

def self.spawn(command)

  PTY.spawn(command) do |r,w,p|
    begin
      yield r,w,p if block_given?
    rescue Errno::EIO
      nil # ignore Errno::EIO: Input/output error @ io_fillbuf
    ensure
      Process.wait p
    end
  end

  $?.exitstatus
end