Class: SubSpawn::Internal::FdSource::PTY

Inherits:
Open show all
Defined in:
lib/subspawn/fd_types.rb

Overview

attr_reader :output

Instance Attribute Summary

Attributes inherited from SubSpawn::Internal::FdSource

#all_dests, #dests

Instance Method Summary collapse

Methods inherited from SubSpawn::Internal::FdSource

#before?, #depends?, #destroys?, #heads, #max, #raw_apply, #tails, #to_dbg

Constructor Details

#initialize(dests) ⇒ PTY

Returns a new instance of PTY.



136
137
138
139
140
# File 'lib/subspawn/fd_types.rb', line 136

def initialize(dests)
	tty, ntty = dests.partition{|x|x == :tty}
	super(ntty, dests)
	@settty = !tty.empty?
end

Instance Method Details

#apply(base) ⇒ Object



141
142
143
144
145
146
147
148
149
150
# File 'lib/subspawn/fd_types.rb', line 141

def apply base
	# MRI doesn't do a chmod for PTY.spawn. Weird, but lets just copy that here
	m,s = (@saved ||= SubSpawn::Platform::PtyHelper.open_internal)
	base.fd_close(m) # if you want the master, pass it in yourself
	raw_apply base, s
	if @settty
		base.tty = s
	end
	SubSpawn::IoHolder::PTY.new(m,s)
end