Class: ZTK::PTY

Inherits:
Object
  • Object
show all
Defined in:
lib/ztk/pty.rb

Overview

Ruby PTY Class Wrapper

Wraps the Ruby PTY class, providing better functionality.

Author:

Class Method Summary (collapse)

Class Method Details

+ (Object) spawn(*args, &block)

Execute a process via a ruby-based PTY.

Parameters:

  • args (Array)

    An argument splat to be passed to PTY::spawn

Returns:

  • (Object)

    Returns the $? object.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/ztk/pty.rb', line 23

def spawn(*args, &block)
  begin
    ::PTY.spawn(*args) do |reader, writer, pid|
      begin
        block_given? and yield(reader, writer, pid)
      rescue Errno::EIO
      ensure
        ::Process.wait(pid)
      end
    end
  rescue ::PTY::ChildExited
  end

  true
end