diff options
Diffstat (limited to 'tokio-signal/examples/multiple.rs')
-rw-r--r-- | tokio-signal/examples/multiple.rs | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/tokio-signal/examples/multiple.rs b/tokio-signal/examples/multiple.rs index b385d54c..98d6edb6 100644 --- a/tokio-signal/examples/multiple.rs +++ b/tokio-signal/examples/multiple.rs @@ -11,7 +11,7 @@ mod platform { use futures::{Future, Stream}; use tokio_signal::unix::{Signal, SIGINT, SIGTERM}; - pub fn main() { + pub fn main() -> Result<(), Box<::std::error::Error>> { // Create a stream for each of the signals we'd like to handle. let sigint = Signal::new(SIGINT).flatten_stream(); let sigterm = Signal::new(SIGTERM).flatten_stream(); @@ -27,26 +27,26 @@ mod platform { (i.e. this binary)" ); let (item, _rest) = ::tokio::runtime::current_thread::block_on_all(stream.into_future()) - .ok() - .unwrap(); + .map_err(|_| "failed to wait for signals")?; // Figure out which signal we received - let item = item.unwrap(); + let item = item.ok_or("received no signal")?; if item == SIGINT { println!("received SIGINT"); } else { assert_eq!(item, SIGTERM); println!("received SIGTERM"); } + Ok(()) } } #[cfg(not(unix))] mod platform { - pub fn main() {} + pub fn main() -> Result<(), Box<::std::error::Error>> {Ok(())} } -fn main() { +fn main() -> Result<(), Box<std::error::Error>> { platform::main() } |