stdlib/pty/0/pty.rbs in rbs-2.0.0 vs stdlib/pty/0/pty.rbs in rbs-2.1.0
- old
+ new
@@ -1,7 +1,8 @@
+# <!-- rdoc-file=ext/pty/pty.c -->
# Creates and manages pseudo terminals (PTYs). See also
-# http://en.wikipedia.org/wiki/Pseudo_terminal
+# https://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
@@ -40,22 +41,27 @@
# end
# p ret #=> nil
#
# ## License
#
-# C) Copyright 1998 by Akinori Ito.
+# (c) Copyright 1998 by Akinori Ito.
#
-# This software may be redistributed freely for this purpose, in full
-# or in part, provided that this entire copyright notice is included
-# on any copies of this software and applications and derivations thereof.
+# This software may be redistributed freely for this purpose, in full or in
+# part, provided that this entire copyright notice is included on any copies of
+# this software and applications and derivations thereof.
#
-# This software is provided on an "as is" basis, without warranty of any
-# kind, either expressed or implied, as to any matter including, but not
-# limited to warranty of fitness of purpose, or merchantability, or
-# results obtained from use of this software.
+# This software is provided on an "as is" basis, without warranty of any kind,
+# either expressed or implied, as to any matter including, but not limited to
+# warranty of fitness of purpose, or merchantability, or results obtained from
+# use of this software.
#
module PTY
+ # <!--
+ # rdoc-file=ext/pty/pty.c
+ # - PTY.check(pid, raise = false) => Process::Status or nil
+ # - PTY.check(pid, true) => nil or raises PTY::ChildExited
+ # -->
# Checks the status of the child process specified by `pid`. Returns `nil` if
# the process is still alive.
#
# If the process is not alive, and `raise` was true, a PTY::ChildExited
# exception will be raised. Otherwise it will return a Process::Status instance.
@@ -66,16 +72,51 @@
# : If `true` and the process identified by `pid` is no longer alive a
# PTY::ChildExited is raised.
#
def self.check: (Integer pid, ?boolish raise) -> Process::Status?
+ # <!--
+ # rdoc-file=ext/pty/pty.c
+ # - PTY.spawn(command_line) { |r, w, pid| ... }
+ # - PTY.spawn(command_line) => [r, w, pid]
+ # - PTY.spawn(command, arguments, ...) { |r, w, pid| ... }
+ # - PTY.spawn(command, arguments, ...) => [r, w, pid]
+ # -->
+ # Spawns the specified command on a newly allocated pty. You can also use the
+ # alias ::getpty.
+ #
+ # The command's controlling tty is set to the slave device of the pty and its
+ # standard input/output/error is redirected to the slave device.
+ #
+ # `command` and `command_line` are the full commands to run, given a String. Any
+ # additional `arguments` will be passed to the command.
+ #
+ # ### Return values
+ #
+ # In the non-block form this returns an array of size three, `[r, w, pid]`.
+ #
+ # In the block form these same values will be yielded to the block:
+ #
+ # `r`
+ # : A readable IO that contains the command's standard output and standard
+ # error
+ # `w`
+ # : A writable IO that is the command's standard input
+ # `pid`
+ # : The process identifier for the command.
+ #
alias self.getpty self.spawn
+ # <!--
+ # rdoc-file=ext/pty/pty.c
+ # - PTY.open => [master_io, slave_file]
+ # - PTY.open {|(master_io, slave_file)| ... } => block value
+ # -->
# 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`.
+ # In the block form, yields an array of two elements (`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|
@@ -101,15 +142,23 @@
# IO#raw! is usable to disable newline conversions:
#
# require 'io/console'
# PTY.open {|m, s|
# s.raw!
- # ...
+ # # ...
# }
+ #
def self.open: () -> [ IO, File ]
- | [A] () { ([ IO , File ]) -> A } -> A
+ | [A] () { ([ IO, File ]) -> A } -> A
+ # <!--
+ # rdoc-file=ext/pty/pty.c
+ # - PTY.spawn(command_line) { |r, w, pid| ... }
+ # - PTY.spawn(command_line) => [r, w, pid]
+ # - PTY.spawn(command, arguments, ...) { |r, w, pid| ... }
+ # - PTY.spawn(command, arguments, ...) => [r, w, pid]
+ # -->
# Spawns the specified command on a newly allocated pty. You can also use the
# alias ::getpty.
#
# The command's controlling tty is set to the slave device of the pty and its
# standard input/output/error is redirected to the slave device.
@@ -128,8 +177,9 @@
# error
# `w`
# : A writable IO that is the command's standard input
# `pid`
# : The process identifier for the command.
+ #
def self.spawn: (*String command) -> [ IO, IO, Integer ]
- | (*String command) {([ IO , IO , Integer ]) -> void } -> void
+ | (*String command) { ([ IO, IO, Integer ]) -> void } -> void
end