Class: Toys::Utils::Exec::Result
- Inherits:
-
Object
- Object
- Toys::Utils::Exec::Result
- Defined in:
- core-docs/toys/utils/exec.rb
Overview
Defined in the toys-core gem
The result returned from a subcommand execution. This includes the identifying name of the execution (if any), the result status of the execution, and any captured stream output.
Possible result statuses are:
- The process failed to start. #failed? will return true, and #exception will return an exception describing the failure (often an errno).
- The process executed and exited with a normal exit code. Either #success? or #error? will return true, and #exit_code will return the numeric exit code.
- The process executed but was terminated by an uncaught signal. #signaled? will return true, and #signal_code will return the numeric signal code.
Instance Attribute Summary collapse
-
#captured_err ⇒ String?
readonly
The captured error string.
-
#captured_out ⇒ String?
readonly
The captured output string.
-
#exception ⇒ Exception?
readonly
The exception raised if a process couldn't be started.
-
#name ⇒ Object
readonly
The subcommand's name.
-
#status ⇒ Process::Status?
readonly
The Ruby process status object, providing various information about the ending state of the process.
Instance Method Summary collapse
-
#effective_code ⇒ Integer
Returns an "effective" exit code, which is always an integer if the process has terminated for any reason.
-
#error? ⇒ boolean
Returns true if the subprocess terminated with a nonzero status, or false if the process failed to start, terminated due to a signal, or returned a zero status.
-
#exit_code ⇒ Integer?
The numeric status code for a process that exited normally,.
-
#failed? ⇒ boolean
Returns true if the subprocess failed to start, or false if the process was able to execute.
-
#signal_code ⇒ Integer?
(also: #term_signal)
The numeric signal code that caused process termination.
-
#signaled? ⇒ boolean
Returns true if the subprocess terminated due to an unhandled signal, or false if the process failed to start or exited normally.
-
#success? ⇒ boolean
Returns true if the subprocess terminated with a zero status, or false if the process failed to start, terminated due to a signal, or returned a nonzero status.
Instance Attribute Details
#captured_err ⇒ String? (readonly)
The captured error string.
750 751 752 |
# File 'core-docs/toys/utils/exec.rb', line 750 def captured_err @captured_err end |
#captured_out ⇒ String? (readonly)
The captured output string.
742 743 744 |
# File 'core-docs/toys/utils/exec.rb', line 742 def captured_out @captured_out end |
#exception ⇒ Exception? (readonly)
The exception raised if a process couldn't be started.
Exactly one of #exception and #status will be non-nil. Exactly one of #exception, #exit_code, or #signal_code will be non-nil.
774 775 776 |
# File 'core-docs/toys/utils/exec.rb', line 774 def exception @exception end |
#name ⇒ Object (readonly)
The subcommand's name.
734 735 736 |
# File 'core-docs/toys/utils/exec.rb', line 734 def name @name end |
#status ⇒ Process::Status? (readonly)
The Ruby process status object, providing various information about the ending state of the process.
Exactly one of #exception and #status will be non-nil.
762 763 764 |
# File 'core-docs/toys/utils/exec.rb', line 762 def status @status end |
Instance Method Details
#effective_code ⇒ Integer
Returns an "effective" exit code, which is always an integer if the process has terminated for any reason. In general, this code will be:
- The same as #exit_code if the process terminated normally with an exit code,
- The convention of
128+signalnumif the process terminated due to a signal, - The convention of 126 if the process could not start due to lack of execution permissions,
- The convention of 127 if the process could not start because the command was not recognized or could not be found, or
- An undefined value between 1 and 255 for other failures.
Note that the normal exit code and signal number cases are stable, but any other cases are subject to change on future releases.
867 868 869 |
# File 'core-docs/toys/utils/exec.rb', line 867 def effective_code # Source available in the toys-core gem end |
#error? ⇒ boolean
Returns true if the subprocess terminated with a nonzero status, or false if the process failed to start, terminated due to a signal, or returned a zero status.
844 845 846 |
# File 'core-docs/toys/utils/exec.rb', line 844 def error? # Source available in the toys-core gem end |
#exit_code ⇒ Integer?
The numeric status code for a process that exited normally,
Exactly one of #exception, #exit_code, or #signal_code will be non-nil.
787 788 789 |
# File 'core-docs/toys/utils/exec.rb', line 787 def exit_code # Source available in the toys-core gem end |
#failed? ⇒ boolean
Returns true if the subprocess failed to start, or false if the process was able to execute.
812 813 814 |
# File 'core-docs/toys/utils/exec.rb', line 812 def failed? # Source available in the toys-core gem end |
#signal_code ⇒ Integer? Also known as: term_signal
The numeric signal code that caused process termination.
Exactly one of #exception, #exit_code, or #signal_code will be non-nil.
801 802 803 |
# File 'core-docs/toys/utils/exec.rb', line 801 def signal_code # Source available in the toys-core gem end |
#signaled? ⇒ boolean
Returns true if the subprocess terminated due to an unhandled signal, or false if the process failed to start or exited normally.
822 823 824 |
# File 'core-docs/toys/utils/exec.rb', line 822 def signaled? # Source available in the toys-core gem end |
#success? ⇒ boolean
Returns true if the subprocess terminated with a zero status, or false if the process failed to start, terminated due to a signal, or returned a nonzero status.
833 834 835 |
# File 'core-docs/toys/utils/exec.rb', line 833 def success? # Source available in the toys-core gem end |