Function chan_signal::notify [] [src]

pub fn notify(signals: &[Signal]) -> Receiver<Signal>

Create a new channel subscribed to the given signals.

The channel returned is never closed.

This is a convenience function for subscribing to multiple signals at once. See the documentation of notify_on for details.

The channel returned has a small buffer to prevent signals from being dropped.

THIS MUST BE CALLED BEFORE ANY OTHER THREADS ARE SPAWNED IN YOUR PROCESS.

Example

use chan_signal::Signal;

let signal = chan_signal::notify(&[Signal::INT, Signal::TERM]);

// Blocks until this process is sent an INT or TERM signal.
// Since the channel is never closed, we can unwrap the received value.
signal.recv().unwrap();