Skip to content

Commit e23c6f3

Browse files
authored
signal: updated Documentation for Signals (#5459)
1 parent 0a50cb3 commit e23c6f3

File tree

2 files changed

+81
-70
lines changed

2 files changed

+81
-70
lines changed

tokio/src/signal/unix.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,11 @@ fn signal_enable(signal: SignalKind, handle: &Handle) -> io::Result<()> {
292292
}
293293
}
294294

295-
/// A stream of events for receiving a particular type of OS signal.
295+
/// An listener for receiving a particular type of OS signal.
296+
///
297+
/// The listener can be turned into a `Stream` using [`SignalStream`].
298+
///
299+
/// [`SignalStream`]: https://docs.rs/tokio-stream/latest/tokio_stream/wrappers/struct.SignalStream.html
296300
///
297301
/// In general signal handling on Unix is a pretty tricky topic, and this
298302
/// structure is no exception! There are some important limitations to keep in
@@ -307,7 +311,7 @@ fn signal_enable(signal: SignalKind, handle: &Handle) -> io::Result<()> {
307311
/// Once `poll` has been called, however, a further signal is guaranteed to
308312
/// be yielded as an item.
309313
///
310-
/// Put another way, any element pulled off the returned stream corresponds to
314+
/// Put another way, any element pulled off the returned listener corresponds to
311315
/// *at least one* signal, but possibly more.
312316
///
313317
/// * Signal handling in general is relatively inefficient. Although some
@@ -345,11 +349,11 @@ fn signal_enable(signal: SignalKind, handle: &Handle) -> io::Result<()> {
345349
/// #[tokio::main]
346350
/// async fn main() -> Result<(), Box<dyn std::error::Error>> {
347351
/// // An infinite stream of hangup signals.
348-
/// let mut stream = signal(SignalKind::hangup())?;
352+
/// let mut sig = signal(SignalKind::hangup())?;
349353
///
350354
/// // Print whenever a HUP signal is received
351355
/// loop {
352-
/// stream.recv().await;
356+
/// sig.recv().await;
353357
/// println!("got signal HUP");
354358
/// }
355359
/// }
@@ -360,7 +364,7 @@ pub struct Signal {
360364
inner: RxFuture,
361365
}
362366

363-
/// Creates a new stream which will receive notifications when the current
367+
/// Creates a new listener which will receive notifications when the current
364368
/// process receives the specified signal `kind`.
365369
///
366370
/// This function will create a new stream which binds to the default reactor.

0 commit comments

Comments
 (0)