PTY

module PTY

Creates and managed pseudo terminals (PTYs). See also en.wikipedia.org/wiki/Pseudo_terminal

PTY allows you to allocate new terminals using ::open or ::spawn a new terminal with a specific command.

Example

In this example we will change the buffering type in the factor command, assuming that factor uses stdio for stdout buffering.

If IO.pipe is used instead of ::open, this code deadlocks because factor's stdout is fully buffered.

# start by requiring the standard library PTY
require 'pty'

master, slave = PTY.open
read, write