[−][src]Struct gaea::os::signals::Signals
Notifications of process signals.
Notes
This will block all signals in the signal set given when creating Signals
,
using sigprocmask
. This means that the program is not interrupt, or in any
way notified of signal until the assiocated OsQueue
is polled.
Implementation notes
On platforms that support kqueue this will use the EVFILT_SIGNAL
event
filter, see implementation notes of the os
module to see what platform
supports kqueue. On Linux it uses signalfd.
Examples
use std::io; use gaea::{event, OsQueue, poll}; use gaea::os::{Signal, Signals, SignalSet}; const SIGNAL_ID: event::Id = event::Id(10); fn main() -> io::Result<()> { let mut os_queue = OsQueue::new()?; let mut events = Vec::new(); // Create a `Signals` instance that will catch signals for us. let mut signals = Signals::new(&mut os_queue, SignalSet::all(), SIGNAL_ID)?; loop { poll::<_, io::Error>(&mut [&mut os_queue], &mut events, None)?; for event in &mut events { match event.id() { // Receive the signal send. SIGNAL_ID => match signals.receive()? { Some(Signal::Interrupt) => println!("Got interrupt signal"), Some(Signal::Terminate) => println!("Got terminate signal"), Some(Signal::Quit) => println!("Got quit signal"), _ => println!("Got unknown signal event: {:?}", event), }, _ => println!("Got unexpected event: {:?}", event), } } } }
Methods
impl Signals
[src]
pub fn new(
os_queue: &mut OsQueue,
signals: SignalSet,
id: Id
) -> Result<Signals>
[src]
os_queue: &mut OsQueue,
signals: SignalSet,
id: Id
) -> Result<Signals>
Create a new signal notifier.
This will cause the associated OsQueue
instance to receive events when
the process receives one of the signals in the signal set.
pub fn receive(&mut self) -> Result<Option<Signal>>
[src]
Receive a signal, if any.
Trait Implementations
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,