pub fn signal(kind: SignalKind) -> Result<Signal>
Expand description

Creates a new stream which will receive notifications when the current process receives the specified signal kind.

This function will create a new stream which binds to the default reactor. The Signal stream is an infinite stream which will receive notifications whenever a signal is received. More documentation can be found on Signal itself, but to reiterate:

  • Signals may be coalesced beyond what the kernel already does.
  • Once a signal handler is registered with the process the underlying libc signal handler is never unregistered.

A Signal stream can be created for a particular signal number multiple times. When a signal is received then all the associated channels will receive the signal notification.

Errors

  • If the lower-level C functions fail for some reason.
  • If the previous initialization of this specific signal failed.
  • If the signal is one of signal_hook::FORBIDDEN

Panics

This function panics if there is no current reactor set, or if the rt feature flag is not enabled.