Class: Libuv::Signal
- Inherits:
-
Handle
- Object
- Q::Promise
- Q::DeferredPromise
- Handle
- Libuv::Signal
- Defined in:
- lib/libuv/signal.rb
Constant Summary collapse
- SIGNALS =
{ :HUP => 1, :SIGHUP => 1, :INT => 2, :SIGINT => 2, :TERM => 15, :SIGTERM => 15, :BREAK => 21, :SIGBREAK => 21, :WINCH => 28, :SIGWINCH => 28 }
Constants included from Assertions
Constants inherited from Q::Promise
Instance Attribute Summary
Attributes inherited from Handle
Attributes inherited from Q::Promise
Instance Method Summary collapse
-
#initialize(reactor) ⇒ Signal
constructor
A new instance of Signal.
-
#start(signal) ⇒ Object
Enables the signal handler.
-
#stop ⇒ Object
Disables the signal handler.
Methods inherited from Handle
#active?, #close, #closed?, #closing?, #ref, #unref
Methods included from Assertions
#assert_block, #assert_boolean, #assert_type
Methods included from Resource
#check_result, #check_result!, #resolve, #to_ptr
Methods inherited from Q::DeferredPromise
Methods inherited from Q::Promise
#catch, #finally, #progress, #ruby_catch, #value
Constructor Details
#initialize(reactor) ⇒ Signal
Returns a new instance of Signal.
26 27 28 29 30 31 32 33 |
# File 'lib/libuv/signal.rb', line 26 def initialize(reactor) @reactor = reactor signal_ptr = ::Libuv::Ext.allocate_handle_signal error = check_result(::Libuv::Ext.signal_init(reactor.handle, signal_ptr)) super(signal_ptr, error) end |
Instance Method Details
#start(signal) ⇒ Object
Enables the signal handler.
36 37 38 39 40 41 42 |
# File 'lib/libuv/signal.rb', line 36 def start(signal) return if @closed signal = SIGNALS[signal] if signal.is_a? Symbol error = check_result ::Libuv::Ext.signal_start(handle, callback(:on_sig), signal) reject(error) if error self end |