pub struct SignalHandle { /* private fields */ }Expand description
Signal handles implement Unix style signal handling on a per-event loop bases.
Windows notes: Reception of some signals is emulated:
- SIGINT is normally delivered when the user presses CTRL+C. However, like on Unix, it is not generated when terminal raw mode is enabled.
- SIGBREAK is delivered when the user pressed CTRL + BREAK.
- SIGHUP is generated when the user closes the console window. On SIGHUP the program is given approximately 10 seconds to perform cleanup. After that Windows will unconditionally terminate it.
- SIGWINCH is raised whenever libuv detects that the console has been resized. When a libuv app is running under a console emulator, or when a 32-bit libuv app is running on 64-bit system, SIGWINCH will be emulated. In such cases SIGWINCH signals may not always be delivered in a timely manner. For a writable TtyHandle libuv will only detect size changes when the cursor is moved. When a readable TtyHandle is used, resizing of the console buffer will be detected only if the handle is in raw mode and is being read.
- Watchers for other signals can be successfully created, but these signals are never received. These signals are: SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGTERM and SIGKILL.
- Calls to raise() or abort() to programmatically raise a signal are not detected by libuv; these will not trigger a signal watcher.
Unix notes
- SIGKILL and SIGSTOP are impossible to catch.
- Handling SIGBUS, SIGFPE, SIGILL or SIGSEGV via libuv results into undefined behavior.
- SIGABRT will not be caught by libuv if generated by abort(), e.g. through assert().
- On Linux SIGRT0 and SIGRT1 (signals 32 and 33) are used by the NPTL pthreads library to manage threads. Installing watchers for those signals will lead to unpredictable behavior and is strongly discouraged. Future versions of libuv may simply reject them.
Implementations§
Source§impl SignalHandle
impl SignalHandle
Sourcepub fn new(loop: &Loop) -> Result<SignalHandle>
pub fn new(loop: &Loop) -> Result<SignalHandle>
Create and initialize a new signal handle
Sourcepub fn start<CB: Into<SignalCB<'static>>>(
&mut self,
cb: CB,
signum: i32,
) -> Result<()>
pub fn start<CB: Into<SignalCB<'static>>>( &mut self, cb: CB, signum: i32, ) -> Result<()>
Start the handle with the given callback, watching for the given signal.
Trait Implementations§
Source§impl Clone for SignalHandle
impl Clone for SignalHandle
Source§fn clone(&self) -> SignalHandle
fn clone(&self) -> SignalHandle
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl From<SignalHandle> for Handle
impl From<SignalHandle> for Handle
Source§fn from(signal: SignalHandle) -> Handle
fn from(signal: SignalHandle) -> Handle
Converts to this type from the input type.
Source§impl HandleTrait for SignalHandle
impl HandleTrait for SignalHandle
Source§fn is_active(&self) -> bool
fn is_active(&self) -> bool
Returns non-zero if the handle is active, zero if it’s inactive. What “active” means
depends on the type of handle: Read more
Source§fn is_closing(&self) -> bool
fn is_closing(&self) -> bool
Returns non-zero if the handle is closing or closed, zero otherwise. Read more
Source§fn close<CB: Into<CloseCB<'static>>>(&mut self, cb: CB)
fn close<CB: Into<CloseCB<'static>>>(&mut self, cb: CB)
Request handle to be closed. close_cb will be called asynchronously after this call. This
MUST be called on each handle before memory is released. Moreover, the memory can only be
released in close_cb or after it has returned. Read more
Source§fn ref(&mut self)
fn ref(&mut self)
Reference the given handle. References are idempotent, that is, if a handle is already
referenced calling this function again will have no effect.
Source§fn unref(&mut self)
fn unref(&mut self)
Un-reference the given handle. References are idempotent, that is, if a handle is not
referenced calling this function again will have no effect.
Source§fn send_buffer_size(&mut self, value: i32) -> Result<i32>
fn send_buffer_size(&mut self, value: i32) -> Result<i32>
Gets or sets the size of the send buffer that the operating system uses for the socket. Read more
Source§fn recv_buffer_size(&mut self, value: i32) -> Result<i32>
fn recv_buffer_size(&mut self, value: i32) -> Result<i32>
Gets or sets the size of the receive buffer that the operating system uses for the socket. Read more
Source§fn get_fileno(&self) -> Result<OsFile>
fn get_fileno(&self) -> Result<OsFile>
Gets the platform dependent file descriptor equivalent. Read more
Source§fn get_type(&self) -> HandleType
fn get_type(&self) -> HandleType
Returns the type of the handle.
Source§impl TryFrom<Handle> for SignalHandle
impl TryFrom<Handle> for SignalHandle
impl Copy for SignalHandle
Auto Trait Implementations§
impl Freeze for SignalHandle
impl RefUnwindSafe for SignalHandle
impl !Send for SignalHandle
impl !Sync for SignalHandle
impl Unpin for SignalHandle
impl UnwindSafe for SignalHandle
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more