Module: Kward::NativeShell::Traps
- Included in:
- Runtime
- Defined in:
- lib/kward/shell/native_traps.rb
Overview
Signal callbacks only enqueue names. Native source runs at interpreter safe points, with the interrupted status restored unless the action exits.
Constant Summary collapse
- INTERACTIVE_SIGNALS =
%w[INT QUIT TERM TSTP TTIN TTOU].freeze
- RUBY_RESERVED_SIGNALS =
%w[ILL FPE BUS SEGV VTALRM].freeze
Instance Method Summary collapse
- #finish(input: $stdin, output: $stdout, error: $stderr) ⇒ Object
- #poll_signals(input: $stdin, output: $stdout, error: $stderr) ⇒ Object
- #with_prompt_input ⇒ Object
- #with_signals ⇒ Object
Instance Method Details
#finish(input: $stdin, output: $stdout, error: $stderr) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/kward/shell/native_traps.rb', line 16 def finish(input: $stdin, output: $stdout, error: $stderr) streams = { 0 => input, 1 => output, 2 => error }.merge(@persistent_descriptors) action = @traps.delete("EXIT") with_signal_handlers { run_trap(action, streams) } if action && !action.empty? @status rescue Flow => flow @status = flow.status rescue SyntaxError, ExpansionError, ExecutionError, SystemCallError, IOError, ArgumentError => e error&.puts("kwsh: #{e.}") @status = 2 end |
#poll_signals(input: $stdin, output: $stdout, error: $stderr) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/kward/shell/native_traps.rb', line 32 def poll_signals(input: $stdin, output: $stdout, error: $stderr) notify_jobs(error: error) run_pending_traps({ 0 => input, 1 => output, 2 => error }.merge(@persistent_descriptors)) rescue Flow => flow @exited = true if flow.kind == :exit @status = flow.status rescue SyntaxError, ExpansionError, ExecutionError, SystemCallError, IOError, ArgumentError => e error&.puts("kwsh: #{e.}") @status = 2 end |
#with_prompt_input ⇒ Object
9 10 11 12 13 14 |
# File 'lib/kward/shell/native_traps.rb', line 9 def with_prompt_input @reading_prompt = true yield ensure @reading_prompt = false end |
#with_signals ⇒ Object
28 29 30 |
# File 'lib/kward/shell/native_traps.rb', line 28 def with_signals with_signal_handlers { yield } end |