Sha256: 24bbb1ba12d5d34825dbfd28236290876d7edaba6f20c7e1fc4d730701a969e2
Contents?: true
Size: 1.07 KB
Versions: 9
Compression:
Stored size: 1.07 KB
Contents
module ZTK # PTY Error Class # # @author Zachary Patten <zachary AT jovelabs DOT com> class PTYError < Error; end # Ruby PTY Class Wrapper # # Wraps the Ruby PTY class, providing better functionality. # # @author Zachary Patten <zachary AT jovelabs DOT com> class PTY require 'pty' class << self # Execute a process via a ruby-based PTY. # # @param [Array] args An argument splat to be passed to PTY::spawn # # @return [Object] Returns the $? object. def spawn(*args, &block) reader, writer, pid = nil begin if block_given? ::PTY.spawn(*args) do |reader, writer, pid| begin yield(reader, writer, pid) rescue Errno::EIO ensure ::Process.wait(pid) end end else raise "You must supply a block!" # reader, writer, pid = ::PTY.spawn(*args) end rescue ::PTY::ChildExited end [reader, writer, pid] end end end end
Version data entries
9 entries across 9 versions & 1 rubygems