open

PTY.open => [master_io, slave_file]
PTY.open {|master_io, slave_file| ... } => block value
Class Public methods

Allocates a pty (pseudo-terminal).

In the block form, yields two arguments master_io, slave_file and the value of the block is returned from open.

The IO and File are both closed after the block completes if they haven't been already closed.

PTY.open {|master, slave|
  p master      #=> #<IO:masterpty:/dev/pts/1>
  p slave      #=> #<File:/dev/pts/1>
  p slave.path #=> "/dev/pts/1"
}

In the non-block form, returns a two element array, [master_io, slave_file].

master, slave = PTY.open
# do something with master for IO, or the slave file

The arguments in both forms are:

master_io

the master of the pty, as an IO.

slave_file

the slave of the pty, as a File. The path to the terminal device is available via slave_file.path

doc_ruby_on_rails
2015-04-29 20:21:35
Comments
Leave a Comment

Please login to continue.