id
stringlengths
22
133
text
stringlengths
40
40.2k
arch
stringclasses
1 value
syntax
stringclasses
1 value
kind
stringclasses
4 values
repo
stringclasses
27 values
path
stringlengths
5
116
license
stringclasses
6 values
commit
stringlengths
40
40
source_host
stringclasses
1 value
category
stringclasses
16 values
source_url
stringlengths
85
196
line_start
int64
1
4.28k
line_end
int64
4
4.31k
tokio-rs/tokio:tokio/src/signal/registry.rs:5
} pub(crate) fn globals() -> Pin<&'static Globals> where OsExtraData: 'static + Send + Sync + Init, OsStorage: 'static + Send + Sync + Init, { lazy_static! { static ref GLOBALS: Pin<Box<Globals>> = Box::pin(Globals { extra: OsExtraData::init(), registry: Registry::new(OsStor...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/registry.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/src/signal/registry.rs
161
220
tokio-rs/tokio:tokio/src/signal/registry.rs:8
let _ = fire.send(()); let results: Vec<()> = third_rx.collect().await; assert_eq!(1, results.len()); }); } #[test] fn broadcast_returns_if_at_least_one_event_fired() { let registry = Registry::new(vec![EventInfo::default()]); registry.record_event(0); ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/registry.rs
MIT
2b909d6805990abf0bc2a5dea9e7267ff87df704
github
async-runtime
https://github.com/tokio-rs/tokio/blob/2b909d6805990abf0bc2a5dea9e7267ff87df704/tokio/src/signal/registry.rs
281
310
tokio-rs/tokio:tokio/src/signal/registry.rs:1
use crate::signal::os::{OsExtraData, OsStorage}; use tokio_sync::mpsc::Sender; use lazy_static::lazy_static; use std::ops; use std::pin::Pin; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Mutex; pub(crate) type EventId = usize; /// State for a specific event, whether a notification is pending delive...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/registry.rs
MIT
7eb264a0d0ee68433b20ecafabed53a70a9d43a4
github
async-runtime
https://github.com/tokio-rs/tokio/blob/7eb264a0d0ee68433b20ecafabed53a70a9d43a4/tokio/src/signal/registry.rs
1
60
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:1
use std::alloc::Layout; use std::future::Future; use std::panic::AssertUnwindSafe; use std::pin::Pin; use std::ptr::{self, NonNull}; use std::task::{Context, Poll}; use std::{fmt, panic}; /// A reusable `Pin<Box<dyn Future<Output = T> + Send>>`. /// /// This type lets you replace the future stored in the box without /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/reusable_box.rs
1
60
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:2
if let Err(future) = self.try_set(future) { *self = Self::new(future); } } /// Replaces the future currently stored in this box. /// /// This function never reallocates, but returns an error if the provided /// future has a different size or alignment from the currently stored ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/reusable_box.rs
41
100
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:3
F: Future<Output = T> + Send + 'static, { // Drop the existing future, catching any panics. let result = panic::catch_unwind(AssertUnwindSafe(|| unsafe { ptr::drop_in_place(self.boxed.as_ptr()); })); // Overwrite the future behind the pointer. This is safe because the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/reusable_box.rs
81
140
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:4
impl<T> Future for ReusableBoxFuture<T> { type Output = T; /// Polls the future stored inside this box. fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> { Pin::into_inner(self).get_pin().poll(cx) } } // The future stored inside ReusableBoxFuture<T> must be Send. unsafe impl<T> Se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/reusable_box.rs
121
180
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:5
use std::future::Future; use std::pin::Pin; use std::task::{Context, Poll}; #[test] fn test_different_futures() { let fut = async move { 10 }; // Not zero sized! assert_eq!(Layout::for_value(&fut).size(), 1); let mut b = ReusableBoxFuture::new(fut); assert_eq!(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/reusable_box.rs
161
220
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:6
b.set(fut3); assert_eq!(b.get_pin().now_or_never(), Some(5)); } struct ZeroSizedFuture {} impl Future for ZeroSizedFuture { type Output = u32; fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<u32> { Poll::Ready(5) } } #[test] fn test_zero...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/reusable_box.rs
201
230
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:2
if let Err(future) = self.try_set(future) { *self = Self::new(future); } } /// Replaces the future currently stored in this box. /// /// This function never reallocates, but returns an error if the provided /// future has a different size or alignment from the currently stored ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
121769c762ad6b1686ecd0e8618005aab8b7e980
github
async-runtime
https://github.com/tokio-rs/tokio/blob/121769c762ad6b1686ecd0e8618005aab8b7e980/tokio/src/signal/reusable_box.rs
41
100
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:3
F: Future<Output = T> + Send + 'static, { // Drop the existing future, catching any panics. let result = panic::catch_unwind(AssertUnwindSafe(|| { ptr::drop_in_place(self.boxed.as_ptr()); })); // Overwrite the future behind the pointer. This is safe because the /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
121769c762ad6b1686ecd0e8618005aab8b7e980
github
async-runtime
https://github.com/tokio-rs/tokio/blob/121769c762ad6b1686ecd0e8618005aab8b7e980/tokio/src/signal/reusable_box.rs
81
140
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:4
/// Polls the future stored inside this box. fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> { Pin::into_inner(self).get_pin().poll(cx) } } // The future stored inside ReusableBoxFuture<T> must be Send. unsafe impl<T> Send for ReusableBoxFuture<T> {} // The only method called on self.bo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
121769c762ad6b1686ecd0e8618005aab8b7e980
github
async-runtime
https://github.com/tokio-rs/tokio/blob/121769c762ad6b1686ecd0e8618005aab8b7e980/tokio/src/signal/reusable_box.rs
121
180
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:5
#[test] fn test_different_futures() { let fut = async move { 10 }; // Not zero sized! assert_eq!(Layout::for_value(&fut).size(), 1); let mut b = ReusableBoxFuture::new(fut); assert_eq!(b.get_pin().now_or_never(), Some(10)); b.try_set(async move { 20 }) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
121769c762ad6b1686ecd0e8618005aab8b7e980
github
async-runtime
https://github.com/tokio-rs/tokio/blob/121769c762ad6b1686ecd0e8618005aab8b7e980/tokio/src/signal/reusable_box.rs
161
220
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:6
struct ZeroSizedFuture {} impl Future for ZeroSizedFuture { type Output = u32; fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<u32> { Poll::Ready(5) } } #[test] fn test_zero_sized() { let fut = ZeroSizedFuture {}; // Zero sized! a...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
121769c762ad6b1686ecd0e8618005aab8b7e980
github
async-runtime
https://github.com/tokio-rs/tokio/blob/121769c762ad6b1686ecd0e8618005aab8b7e980/tokio/src/signal/reusable_box.rs
201
227
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:4
/// Polls the future stored inside this box. fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> { Pin::into_inner(self).get_pin().poll(cx) } } // The future stored inside ReusableBoxFuture<T> must be Send. unsafe impl<T> Send for ReusableBoxFuture<T> {} // The only method called on self.bo...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/signal/reusable_box.rs
121
180
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:5
use std::task::{Context, Poll}; #[test] fn test_different_futures() { let fut = async move { 10 }; // Not zero sized! assert_eq!(Layout::for_value(&fut).size(), 1); let mut b = ReusableBoxFuture::new(fut); assert_eq!(b.get_pin().now_or_never(), Some(10)); b.tr...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/signal/reusable_box.rs
161
220
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:6
} struct ZeroSizedFuture {} impl Future for ZeroSizedFuture { type Output = u32; fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<u32> { Poll::Ready(5) } } #[test] fn test_zero_sized() { let fut = ZeroSizedFuture {}; // Zero sized! ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
1be8e9dfb7b1140568ac10ac34f5f8171a89e40d
github
async-runtime
https://github.com/tokio-rs/tokio/blob/1be8e9dfb7b1140568ac10ac34f5f8171a89e40d/tokio/src/signal/reusable_box.rs
201
228
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:1
use std::alloc::Layout; use std::future::Future; use std::panic::AssertUnwindSafe; use std::pin::Pin; use std::ptr::{self, NonNull}; use std::task::{Context, Poll}; use std::{fmt, panic}; /// A reusable `Pin<Box<dyn Future<Output = T> + Send>>`. /// /// This type lets you replace the future stored in the box without /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
e4f76688a00fa2ce81ab6c074700995095c29e1e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/reusable_box.rs
1
60
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:2
if let Err(future) = self.try_set(future) { *self = Self::new(future); } } /// Replace the future currently stored in this box. /// /// This function never reallocates, but returns an error if the provided /// future has a different size or alignment from the currently stored ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
e4f76688a00fa2ce81ab6c074700995095c29e1e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/reusable_box.rs
41
100
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:3
F: Future<Output = T> + Send + 'static, { // Drop the existing future, catching any panics. let result = panic::catch_unwind(AssertUnwindSafe(|| { ptr::drop_in_place(self.boxed.as_ptr()); })); // Overwrite the future behind the pointer. This is safe because the /...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
e4f76688a00fa2ce81ab6c074700995095c29e1e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/reusable_box.rs
81
140
tokio-rs/tokio:tokio/src/signal/reusable_box.rs:4
/// Poll the future stored inside this box. fn poll(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<T> { Pin::into_inner(self).get_pin().poll(cx) } } // The future stored inside ReusableBoxFuture<T> must be Send. unsafe impl<T> Send for ReusableBoxFuture<T> {} // The only method called on self.box...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/reusable_box.rs
MIT
e4f76688a00fa2ce81ab6c074700995095c29e1e
github
async-runtime
https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/reusable_box.rs
121
180
tokio-rs/tokio:tokio/src/signal/unix.rs:1
//! Unix-specific types for signal handling. //! //! This module is only defined on Unix platforms and contains the primary //! `Signal` type for receiving notifications of signals. #![cfg(unix)] #![cfg_attr(docsrs, doc(cfg(all(unix, feature = "signal"))))] use crate::runtime::scheduler; use crate::runtime::signal::H...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
1
60
tokio-rs/tokio:tokio/src/signal/unix.rs:2
#[cfg(any(target_os = "linux", target_os = "illumos"))] let inner = std::iter::repeat_with(SignalInfo::default) .take(libc::SIGRTMAX() as usize) .collect(); Self(inner) } } impl Storage for OsStorage { fn event_info(&self, id: EventId) -> Option<&EventInfo> { se...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
41
100
tokio-rs/tokio:tokio/src/signal/unix.rs:3
impl SignalKind { /// Allows for listening to any valid OS signal. /// /// For example, this can be used for listening for platform-specific /// signals. /// ```rust,no_run /// # use tokio::signal::unix::SignalKind; /// # let signum = -1; /// // let signum = libc::OS_SPECIFIC_SIGNAL; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
81
140
tokio-rs/tokio:tokio/src/signal/unix.rs:4
/// Represents the `SIGCHLD` signal. /// /// On Unix systems this signal is sent when the status of a child process /// has changed. By default, this signal is ignored. pub const fn child() -> Self { Self(libc::SIGCHLD) } /// Represents the `SIGHUP` signal. /// /// On Unix syste...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
121
180
tokio-rs/tokio:tokio/src/signal/unix.rs:5
#[cfg(target_os = "haiku")] /// Represents the `SIGPOLL` signal. /// /// On POSIX systems this signal is sent when I/O operations are possible /// on some file descriptor. By default, this signal is ignored. pub const fn io() -> Self { Self(libc::SIGPOLL) } #[cfg(not(target_os = "hai...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
161
220
tokio-rs/tokio:tokio/src/signal/unix.rs:6
Self(libc::SIGTERM) } /// Represents the `SIGUSR1` signal. /// /// On Unix systems this is a user defined signal. /// By default, the process is terminated by this signal. pub const fn user_defined1() -> Self { Self(libc::SIGUSR1) } /// Represents the `SIGUSR2` signal. /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
201
260
tokio-rs/tokio:tokio/src/signal/unix.rs:7
#[derive(Default)] pub(crate) struct SignalInfo { event_info: EventInfo, init: OnceLock<Result<(), Option<i32>>>, } /// Our global signal handler for all signals registered by this module. /// /// The purpose of this signal handler is to primarily: /// /// 1. Flag that our specific signal was received (e.g. st...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
241
300
tokio-rs/tokio:tokio/src/signal/unix.rs:8
let globals = globals(); let siginfo = match globals.storage().get(signal as EventId) { Some(slot) => slot, None => return Err(io::Error::new(io::ErrorKind::Other, "signal too large")), }; siginfo .init .get_or_init(|| { unsafe { signal_hook_registry::register(si...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
281
340
tokio-rs/tokio:tokio/src/signal/unix.rs:10
/// // Print whenever a HUP signal is received /// loop { /// sig.recv().await; /// println!("got signal HUP"); /// } /// } /// ``` #[must_use = "streams do nothing unless polled"] #[derive(Debug)] pub struct Signal { inner: RxFuture, } /// Creates a new listener which will receive noti...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
361
420
tokio-rs/tokio:tokio/src/signal/unix.rs:11
#[track_caller] pub fn signal(kind: SignalKind) -> io::Result<Signal> { let handle = scheduler::Handle::current(); let rx = signal_with_handle(kind, handle.driver().signal())?; Ok(Signal { inner: RxFuture::new(rx), }) } pub(crate) fn signal_with_handle( kind: SignalKind, handle: &Handl...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
401
460
tokio-rs/tokio:tokio/src/signal/unix.rs:12
/// async fn main() -> Result<(), Box<dyn std::error::Error>> { /// // An infinite stream of hangup signals. /// let mut stream = signal(SignalKind::hangup())?; /// /// // Print whenever a HUP signal is received /// loop { /// stream.recv().await; /// println!...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
441
500
tokio-rs/tokio:tokio/src/signal/unix.rs:13
/// println!("polling MyFuture"); /// self.signal.poll_recv(cx) /// } /// } /// ``` pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> { self.inner.poll_recv(cx).map(Some) } } // Work around for abstracting streams internally #[cfg(feature = "proce...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
481
540
tokio-rs/tokio:tokio/src/signal/unix.rs:14
ErrorKind::Other, ); } } #[test] fn signal_enable_error_on_forbidden_input() { let inputs = signal_hook_registry::FORBIDDEN; for &input in inputs { assert_eq!( signal_enable(SignalKind::from_raw(input), &Handle::default()) ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17
github
async-runtime
https://github.com/tokio-rs/tokio/blob/c6d58ce7e7bf4a6e7e6efc1ffeb42daa3a627c17/tokio/src/signal/unix.rs
521
550
tokio-rs/tokio:tokio/src/signal/unix.rs:11
#[track_caller] pub fn signal(kind: SignalKind) -> io::Result<Signal> { let handle = scheduler::Handle::current(); let rx = signal_with_handle(kind, handle.driver().signal())?; Ok(Signal { inner: RxFuture::new(rx), }) } pub(crate) fn signal_with_handle( kind: SignalKind, handle: &Handl...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
240cc44da87ac30188e946ed1003b0e67f64aad8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/240cc44da87ac30188e946ed1003b0e67f64aad8/tokio/src/signal/unix.rs
401
460
tokio-rs/tokio:tokio/src/signal/unix.rs:13
/// type Output = Option<()>; /// /// fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { /// println!("polling MyFuture"); /// self.signal.poll_recv(cx) /// } /// } /// ``` pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
240cc44da87ac30188e946ed1003b0e67f64aad8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/240cc44da87ac30188e946ed1003b0e67f64aad8/tokio/src/signal/unix.rs
481
540
tokio-rs/tokio:tokio/src/signal/unix.rs:14
signal_enable(SignalKind::from_raw(input), &Handle::default()) .unwrap_err() .kind(), ErrorKind::Other, ); } } #[test] fn signal_enable_error_on_forbidden_input() { let inputs = signal_hook_registry::FORBIDDEN; for...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
240cc44da87ac30188e946ed1003b0e67f64aad8
github
async-runtime
https://github.com/tokio-rs/tokio/blob/240cc44da87ac30188e946ed1003b0e67f64aad8/tokio/src/signal/unix.rs
521
553
tokio-rs/tokio:tokio/src/signal/unix.rs:1
//! Unix-specific types for signal handling. //! //! This module is only defined on Unix platforms and contains the primary //! `Signal` type for receiving notifications of signals. #![cfg(unix)] #![cfg_attr(docsrs, doc(cfg(all(unix, feature = "signal"))))] use crate::runtime::scheduler; use crate::runtime::signal::H...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
1
60
tokio-rs/tokio:tokio/src/signal/unix.rs:2
// verified before being enabled.) #[cfg(any(target_os = "linux", target_os = "illumos"))] let inner = std::iter::repeat_with(SignalInfo::default) .take(libc::SIGRTMAX() as usize) .collect(); Self(inner) } } impl Storage for OsStorage { fn event_info(&self, id: ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
41
100
tokio-rs/tokio:tokio/src/signal/unix.rs:3
impl SignalKind { /// Allows for listening to any valid OS signal. /// /// For example, this can be used for listening for platform-specific /// signals. /// ```rust,no_run /// # use tokio::signal::unix::SignalKind; /// # let signum = -1; /// // let signum = libc::OS_SPECIFIC_SIGNAL; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
81
140
tokio-rs/tokio:tokio/src/signal/unix.rs:4
/// Represents the `SIGCHLD` signal. /// /// On Unix systems this signal is sent when the status of a child process /// has changed. By default, this signal is ignored. pub const fn child() -> Self { Self(libc::SIGCHLD) } /// Represents the `SIGHUP` signal. /// /// On Unix syste...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
121
180
tokio-rs/tokio:tokio/src/signal/unix.rs:5
#[cfg(target_os = "haiku")] /// Represents the `SIGPOLL` signal. /// /// On POSIX systems this signal is sent when I/O operations are possible /// on some file descriptor. By default, this signal is ignored. pub const fn io() -> Self { Self(libc::SIGPOLL) } #[cfg(not(target_os = "hai...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
161
220
tokio-rs/tokio:tokio/src/signal/unix.rs:6
pub const fn terminate() -> Self { Self(libc::SIGTERM) } /// Represents the `SIGUSR1` signal. /// /// On Unix systems this is a user defined signal. /// By default, the process is terminated by this signal. pub const fn user_defined1() -> Self { Self(libc::SIGUSR1) } //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
201
260
tokio-rs/tokio:tokio/src/signal/unix.rs:7
pub(crate) struct SignalInfo { event_info: EventInfo, init: Once, initialized: AtomicBool, } impl Default for SignalInfo { fn default() -> SignalInfo { SignalInfo { event_info: EventInfo::default(), init: Once::new(), initialized: AtomicBool::new(false), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
241
300
tokio-rs/tokio:tokio/src/signal/unix.rs:8
let signal = signal.0; if signal <= 0 || signal_hook_registry::FORBIDDEN.contains(&signal) { return Err(Error::new( ErrorKind::Other, format!("Refusing to register signal {signal}"), )); } // Check that we have a signal driver running handle.check_inner()?; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
281
340
tokio-rs/tokio:tokio/src/signal/unix.rs:11
/// 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...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
401
460
tokio-rs/tokio:tokio/src/signal/unix.rs:13
/// sent before it was closed have been received. /// /// # Examples /// /// Polling from a manually implemented future /// /// ```rust,no_run /// use std::pin::Pin; /// use std::future::Future; /// use std::task::{Context, Poll}; /// use tokio::signal::unix::Signal; /// ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
481
540
tokio-rs/tokio:tokio/src/signal/unix.rs:14
} } pub(crate) fn ctrl_c() -> io::Result<Signal> { signal(SignalKind::interrupt()) } #[cfg(all(test, not(loom)))] mod tests { use super::*; #[test] fn signal_enable_error_on_invalid_input() { let inputs = [-1, 0]; for input in inputs { assert_eq!( signal_e...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
521
570
tokio-rs/tokio:tokio/src/signal/unix.rs:15
fn from_c_int() { assert_eq!(SignalKind::from(2), SignalKind::interrupt()); } #[test] fn into_c_int() { let value: std::os::raw::c_int = SignalKind::interrupt().into(); assert_eq!(value, libc::SIGINT as _); } }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
46674789abdcd72189bb48a82c6c2121bc3922a0
github
async-runtime
https://github.com/tokio-rs/tokio/blob/46674789abdcd72189bb48a82c6c2121bc3922a0/tokio/src/signal/unix.rs
561
570
tokio-rs/tokio:tokio/src/signal/unix.rs:1
//! Unix-specific types for signal handling. //! //! This module is only defined on Unix platforms and contains the primary //! `Signal` type for receiving notifications of signals. #![cfg(unix)] #![cfg_attr(docsrs, doc(cfg(all(unix, feature = "signal"))))] use crate::runtime::scheduler; use crate::runtime::signal::H...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
1
60
tokio-rs/tokio:tokio/src/signal/unix.rs:2
} impl Storage for OsStorage { fn event_info(&self, id: EventId) -> Option<&EventInfo> { self.get(id).map(|si| &si.event_info) } fn for_each<'a, F>(&'a self, f: F) where F: FnMut(&'a EventInfo), { self.iter().map(|si| &si.event_info).for_each(f); } } #[derive(Debug)] p...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
41
100
tokio-rs/tokio:tokio/src/signal/unix.rs:3
/// # let signum = -1; /// // let signum = libc::OS_SPECIFIC_SIGNAL; /// let kind = SignalKind::from_raw(signum); /// ``` // Use `std::os::raw::c_int` on public API to prevent leaking a non-stable // type alias from libc. // `libc::c_int` and `std::os::raw::c_int` are currently the same type, an...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
81
140
tokio-rs/tokio:tokio/src/signal/unix.rs:4
/// Represents the `SIGHUP` signal. /// /// On Unix systems this signal is sent when the terminal is disconnected. /// By default, the process is terminated by this signal. pub const fn hangup() -> Self { Self(libc::SIGHUP) } /// Represents the `SIGINFO` signal. /// /// On Unix ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
121
180
tokio-rs/tokio:tokio/src/signal/unix.rs:5
} #[cfg(not(target_os = "haiku"))] /// Represents the `SIGIO` signal. /// /// On Unix systems this signal is sent when I/O operations are possible /// on some file descriptor. By default, this signal is ignored. pub const fn io() -> Self { Self(libc::SIGIO) } /// Represents the ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
161
220
tokio-rs/tokio:tokio/src/signal/unix.rs:6
pub const fn user_defined1() -> Self { Self(libc::SIGUSR1) } /// Represents the `SIGUSR2` signal. /// /// On Unix systems this is a user defined signal. /// By default, the process is terminated by this signal. pub const fn user_defined2() -> Self { Self(libc::SIGUSR2) } ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
201
260
tokio-rs/tokio:tokio/src/signal/unix.rs:7
fn default() -> SignalInfo { SignalInfo { event_info: EventInfo::default(), init: Once::new(), initialized: AtomicBool::new(false), } } } /// Our global signal handler for all signals registered by this module. /// /// The purpose of this signal handler is to pri...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
241
300
tokio-rs/tokio:tokio/src/signal/unix.rs:8
// Check that we have a signal driver running handle.check_inner()?; let globals = globals(); let siginfo = match globals.storage().get(signal as EventId) { Some(slot) => slot, None => return Err(io::Error::new(io::ErrorKind::Other, "signal too large")), }; let mut registered = Ok((...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
281
340
tokio-rs/tokio:tokio/src/signal/unix.rs:10
/// /// ```rust,no_run /// use tokio::signal::unix::{signal, SignalKind}; /// /// #[tokio::main] /// async fn main() -> Result<(), Box<dyn std::error::Error>> { /// // An infinite stream of hangup signals. /// let mut sig = signal(SignalKind::hangup())?; /// /// // Print whenever a HUP signal is received //...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
361
420
tokio-rs/tokio:tokio/src/signal/unix.rs:11
/// * 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`](fn@signal_hook_registry::register#panics) /// /// # Panics /// /// This function panics if there is no current reactor set, or if...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
401
460
tokio-rs/tokio:tokio/src/signal/unix.rs:13
/// use std::future::Future; /// use std::task::{Context, Poll}; /// use tokio::signal::unix::Signal; /// /// struct MyFuture { /// signal: Signal, /// } /// /// impl Future for MyFuture { /// type Output = Option<()>; /// /// fn poll(mut self: Pin<&mut Self>, cx:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
481
540
tokio-rs/tokio:tokio/src/signal/unix.rs:14
mod tests { use super::*; #[test] fn signal_enable_error_on_invalid_input() { signal_enable(SignalKind::from_raw(-1), &Handle::default()).unwrap_err(); } #[test] fn signal_enable_error_on_forbidden_input() { signal_enable( SignalKind::from_raw(signal_hook_registry::...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
8f4ebfd2f7f120e6f50448509496614d7008aef3
github
async-runtime
https://github.com/tokio-rs/tokio/blob/8f4ebfd2f7f120e6f50448509496614d7008aef3/tokio/src/signal/unix.rs
521
548
tokio-rs/tokio:tokio/src/signal/unix.rs:1
//! Unix-specific types for signal handling. //! //! This module is only defined on Unix platforms and contains the primary //! `Signal` type for receiving notifications of signals. #![cfg(unix)] #![cfg_attr(docsrs, doc(cfg(all(unix, feature = "signal"))))] use crate::runtime::scheduler; use crate::runtime::signal::H...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
1
60
tokio-rs/tokio:tokio/src/signal/unix.rs:2
self.get(id).map(|si| &si.event_info) } fn for_each<'a, F>(&'a self, f: F) where F: FnMut(&'a EventInfo), { self.iter().map(|si| &si.event_info).for_each(f); } } #[derive(Debug)] pub(crate) struct OsExtraData { sender: UnixStream, pub(crate) receiver: UnixStream, } impl In...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
41
100
tokio-rs/tokio:tokio/src/signal/unix.rs:3
// Use `std::os::raw::c_int` on public API to prevent leaking a non-stable // type alias from libc. // `libc::c_int` and `std::os::raw::c_int` are currently the same type, and are // unlikely to change to other types, but technically libc can change this // in the future minor version. // See https:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
81
140
tokio-rs/tokio:tokio/src/signal/unix.rs:4
/// By default, the process is terminated by this signal. pub const fn hangup() -> Self { Self(libc::SIGHUP) } /// Represents the `SIGINFO` signal. /// /// On Unix systems this signal is sent to request a status update from the /// process. By default, this signal is ignored. #[cfg(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
121
180
tokio-rs/tokio:tokio/src/signal/unix.rs:5
/// On Unix systems this signal is sent when I/O operations are possible /// on some file descriptor. By default, this signal is ignored. pub const fn io() -> Self { Self(libc::SIGIO) } /// Represents the `SIGPIPE` signal. /// /// On Unix systems this signal is sent when the process att...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
161
220
tokio-rs/tokio:tokio/src/signal/unix.rs:6
/// Represents the `SIGUSR2` signal. /// /// On Unix systems this is a user defined signal. /// By default, the process is terminated by this signal. pub const fn user_defined2() -> Self { Self(libc::SIGUSR2) } /// Represents the `SIGWINCH` signal. /// /// On Unix systems this s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
201
260
tokio-rs/tokio:tokio/src/signal/unix.rs:7
initialized: AtomicBool::new(false), } } } /// Our global signal handler for all signals registered by this module. /// /// The purpose of this signal handler is to primarily: /// /// 1. Flag that our specific signal was received (e.g. store an atomic flag) /// 2. Wake up the driver by writing a byte to a ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
241
300
tokio-rs/tokio:tokio/src/signal/unix.rs:8
let siginfo = match globals.storage().get(signal as EventId) { Some(slot) => slot, None => return Err(io::Error::new(io::ErrorKind::Other, "signal too large")), }; let mut registered = Ok(()); siginfo.init.call_once(|| { registered = unsafe { signal_hook_registry::registe...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
281
340
tokio-rs/tokio:tokio/src/signal/unix.rs:10
/// #[tokio::main] /// async fn main() -> Result<(), Box<dyn std::error::Error>> { /// // An infinite stream of hangup signals. /// let mut sig = signal(SignalKind::hangup())?; /// /// // Print whenever a HUP signal is received /// loop { /// sig.recv().await; /// println!("got signal HU...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
361
420
tokio-rs/tokio:tokio/src/signal/unix.rs:11
/// /// # Panics /// /// This function panics if there is no current reactor set, or if the `rt` /// feature flag is not enabled. #[track_caller] pub fn signal(kind: SignalKind) -> io::Result<Signal> { let handle = scheduler::Handle::current(); let rx = signal_with_handle(kind, handle.driver().signal())?; ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
401
460
tokio-rs/tokio:tokio/src/signal/unix.rs:13
/// struct MyFuture { /// signal: Signal, /// } /// /// impl Future for MyFuture { /// type Output = Option<()>; /// /// fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { /// println!("polling MyFuture"); /// self.signal.poll_...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
481
540
tokio-rs/tokio:tokio/src/signal/unix.rs:14
fn signal_enable_error_on_invalid_input() { signal_enable(SignalKind::from_raw(-1), &Handle::default()).unwrap_err(); } #[test] fn signal_enable_error_on_forbidden_input() { signal_enable( SignalKind::from_raw(signal_hook_registry::FORBIDDEN[0]), &Handle::default(), ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
9d42b977df149363c11257c77c465efe4ce288ee
github
async-runtime
https://github.com/tokio-rs/tokio/blob/9d42b977df149363c11257c77c465efe4ce288ee/tokio/src/signal/unix.rs
521
544
tokio-rs/tokio:tokio/src/signal/unix.rs:4
/// By default, the process is terminated by this signal. pub const fn hangup() -> Self { Self(libc::SIGHUP) } /// Represents the `SIGINFO` signal. /// /// On Unix systems this signal is sent to request a status update from the /// process. By default, this signal is ignored. #[cfg(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
aa7e0cef725814251b5c24b52b4d0eb042405e58
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aa7e0cef725814251b5c24b52b4d0eb042405e58/tokio/src/signal/unix.rs
121
180
tokio-rs/tokio:tokio/src/signal/unix.rs:5
/// to a pipe which has no reader. By default, the process is terminated by /// this signal. pub const fn pipe() -> Self { Self(libc::SIGPIPE) } /// Represents the `SIGQUIT` signal. /// /// On Unix systems this signal is sent to issue a shutdown of the /// process, after which the O...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
aa7e0cef725814251b5c24b52b4d0eb042405e58
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aa7e0cef725814251b5c24b52b4d0eb042405e58/tokio/src/signal/unix.rs
161
220
tokio-rs/tokio:tokio/src/signal/unix.rs:6
/// /// On Unix systems this signal is sent when the terminal window is resized. /// By default, this signal is ignored. pub const fn window_change() -> Self { Self(libc::SIGWINCH) } } impl From<std::os::raw::c_int> for SignalKind { fn from(signum: std::os::raw::c_int) -> Self { Sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
aa7e0cef725814251b5c24b52b4d0eb042405e58
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aa7e0cef725814251b5c24b52b4d0eb042405e58/tokio/src/signal/unix.rs
201
260
tokio-rs/tokio:tokio/src/signal/unix.rs:7
/// 1. Flag that our specific signal was received (e.g. store an atomic flag) /// 2. Wake up the driver by writing a byte to a pipe /// /// Those two operations should both be async-signal safe. fn action(globals: &'static Globals, signal: libc::c_int) { globals.record_event(signal as EventId); // Send a wakeu...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
aa7e0cef725814251b5c24b52b4d0eb042405e58
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aa7e0cef725814251b5c24b52b4d0eb042405e58/tokio/src/signal/unix.rs
241
300
tokio-rs/tokio:tokio/src/signal/unix.rs:8
if registered.is_ok() { siginfo.initialized.store(true, Ordering::Relaxed); } }); registered?; // If the call_once failed, it won't be retried on the next attempt to register the signal. In // such case it is not run, registered is still `Ok(())`, initialized is still `false`. if...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
aa7e0cef725814251b5c24b52b4d0eb042405e58
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aa7e0cef725814251b5c24b52b4d0eb042405e58/tokio/src/signal/unix.rs
281
340
tokio-rs/tokio:tokio/src/signal/unix.rs:10
/// } /// } /// ``` #[must_use = "streams do nothing unless polled"] #[derive(Debug)] pub struct Signal { inner: RxFuture, } /// Creates a new listener which will receive notifications when the current /// process receives the specified signal `kind`. /// /// This function will create a new stream which binds ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
aa7e0cef725814251b5c24b52b4d0eb042405e58
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aa7e0cef725814251b5c24b52b4d0eb042405e58/tokio/src/signal/unix.rs
361
420
tokio-rs/tokio:tokio/src/signal/unix.rs:11
Ok(Signal { inner: RxFuture::new(rx), }) } pub(crate) fn signal_with_handle( kind: SignalKind, handle: &Handle, ) -> io::Result<watch::Receiver<()>> { // Turn the signal delivery on once we are ready for it signal_enable(kind, handle)?; Ok(globals().register_listener(kind.0 as EventId)...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
aa7e0cef725814251b5c24b52b4d0eb042405e58
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aa7e0cef725814251b5c24b52b4d0eb042405e58/tokio/src/signal/unix.rs
401
460
tokio-rs/tokio:tokio/src/signal/unix.rs:12
/// loop { /// stream.recv().await; /// println!("got signal HUP"); /// } /// } /// ``` pub async fn recv(&mut self) -> Option<()> { self.inner.recv().await } /// Polls to receive the next signal notification event, outside of an /// `async` context. ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
aa7e0cef725814251b5c24b52b4d0eb042405e58
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aa7e0cef725814251b5c24b52b4d0eb042405e58/tokio/src/signal/unix.rs
441
500
tokio-rs/tokio:tokio/src/signal/unix.rs:13
/// self.signal.poll_recv(cx) /// } /// } /// ``` pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> { self.inner.poll_recv(cx) } } // Work around for abstracting streams internally #[cfg(feature = "process")] pub(crate) trait InternalStream { fn poll_recv...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
aa7e0cef725814251b5c24b52b4d0eb042405e58
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aa7e0cef725814251b5c24b52b4d0eb042405e58/tokio/src/signal/unix.rs
481
535
tokio-rs/tokio:tokio/src/signal/unix.rs:14
) .unwrap_err(); } #[test] fn from_c_int() { assert_eq!(SignalKind::from(2), SignalKind::interrupt()); } #[test] fn into_c_int() { let value: std::os::raw::c_int = SignalKind::interrupt().into(); assert_eq!(value, libc::SIGINT as _); } }
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
aa7e0cef725814251b5c24b52b4d0eb042405e58
github
async-runtime
https://github.com/tokio-rs/tokio/blob/aa7e0cef725814251b5c24b52b4d0eb042405e58/tokio/src/signal/unix.rs
521
535
tokio-rs/tokio:tokio/src/signal/unix.rs:1
//! Unix-specific types for signal handling. //! //! This module is only defined on Unix platforms and contains the primary //! `Signal` type for receiving notifications of signals. #![cfg(unix)] #![cfg_attr(docsrs, doc(cfg(all(unix, feature = "signal"))))] use crate::runtime::scheduler; use crate::runtime::signal::H...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
1
60
tokio-rs/tokio:tokio/src/signal/unix.rs:2
// does. #[cfg(target_os = "illumos")] let possible = 0..=41; possible.map(|_| SignalInfo::default()).collect() } } impl Storage for OsStorage { fn event_info(&self, id: EventId) -> Option<&EventInfo> { self.get(id).map(|si| &si.event_info) } fn for_each<'a, F>(&'a sel...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
41
100
tokio-rs/tokio:tokio/src/signal/unix.rs:3
/// Allows for listening to any valid OS signal. /// /// For example, this can be used for listening for platform-specific /// signals. /// ```rust,no_run /// # use tokio::signal::unix::SignalKind; /// # let signum = -1; /// // let signum = libc::OS_SPECIFIC_SIGNAL; /// let kind = Signal...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
81
140
tokio-rs/tokio:tokio/src/signal/unix.rs:4
/// /// On Unix systems this signal is sent when the status of a child process /// has changed. By default, this signal is ignored. pub const fn child() -> Self { Self(libc::SIGCHLD) } /// Represents the `SIGHUP` signal. /// /// On Unix systems this signal is sent when the terminal ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
121
180
tokio-rs/tokio:tokio/src/signal/unix.rs:5
/// /// On Unix systems this signal is sent when I/O operations are possible /// on some file descriptor. By default, this signal is ignored. pub const fn io() -> Self { Self(libc::SIGIO) } /// Represents the `SIGPIPE` signal. /// /// On Unix systems this signal is sent when the pro...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
161
220
tokio-rs/tokio:tokio/src/signal/unix.rs:6
/// Represents the `SIGUSR2` signal. /// /// On Unix systems this is a user defined signal. /// By default, the process is terminated by this signal. pub const fn user_defined2() -> Self { Self(libc::SIGUSR2) } /// Represents the `SIGWINCH` signal. /// /// On Unix systems this s...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
201
260
tokio-rs/tokio:tokio/src/signal/unix.rs:7
init: Once::new(), initialized: AtomicBool::new(false), } } } /// Our global signal handler for all signals registered by this module. /// /// The purpose of this signal handler is to primarily: /// /// 1. Flag that our specific signal was received (e.g. store an atomic flag) /// 2. Wake up the...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
241
300
tokio-rs/tokio:tokio/src/signal/unix.rs:8
let globals = globals(); let siginfo = match globals.storage().get(signal as EventId) { Some(slot) => slot, None => return Err(io::Error::new(io::ErrorKind::Other, "signal too large")), }; let mut registered = Ok(()); siginfo.init.call_once(|| { registered = unsafe { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
281
340
tokio-rs/tokio:tokio/src/signal/unix.rs:10
/// /// #[tokio::main] /// async fn main() -> Result<(), Box<dyn std::error::Error>> { /// // An infinite stream of hangup signals. /// let mut sig = signal(SignalKind::hangup())?; /// /// // Print whenever a HUP signal is received /// loop { /// sig.recv().await; /// println!("got signa...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
361
420
tokio-rs/tokio:tokio/src/signal/unix.rs:11
/// [`signal_hook::FORBIDDEN`](fn@signal_hook_registry::register#panics) /// /// # Panics /// /// This function panics if there is no current reactor set, or if the `rt` /// feature flag is not enabled. #[track_caller] pub fn signal(kind: SignalKind) -> io::Result<Signal> { let handle = scheduler::Handle::current...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
401
460
tokio-rs/tokio:tokio/src/signal/unix.rs:13
/// /// struct MyFuture { /// signal: Signal, /// } /// /// impl Future for MyFuture { /// type Output = Option<()>; /// /// fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> { /// println!("polling MyFuture"); /// self.sign...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
481
540
tokio-rs/tokio:tokio/src/signal/unix.rs:14
#[test] fn signal_enable_error_on_invalid_input() { signal_enable(SignalKind::from_raw(-1), &Handle::default()).unwrap_err(); } #[test] fn signal_enable_error_on_forbidden_input() { signal_enable( SignalKind::from_raw(signal_hook_registry::FORBIDDEN[0]), &Handle:...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
480c010b01cf32e36d6cba307ca436fabb6d95fa
github
async-runtime
https://github.com/tokio-rs/tokio/blob/480c010b01cf32e36d6cba307ca436fabb6d95fa/tokio/src/signal/unix.rs
521
545
tokio-rs/tokio:tokio/src/signal/unix.rs:1
//! Unix-specific types for signal handling. //! //! This module is only defined on Unix platforms and contains the primary //! `Signal` type for receiving notifications of signals. #![cfg(unix)] #![cfg_attr(docsrs, doc(cfg(all(unix, feature = "signal"))))] use crate::runtime::scheduler; use crate::runtime::signal::H...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/signal/unix.rs
1
60
tokio-rs/tokio:tokio/src/signal/unix.rs:2
fn for_each<'a, F>(&'a self, f: F) where F: FnMut(&'a EventInfo), { self.iter().map(|si| &si.event_info).for_each(f); } } #[derive(Debug)] pub(crate) struct OsExtraData { sender: UnixStream, pub(crate) receiver: UnixStream, } impl Init for OsExtraData { fn init() -> Self { ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/signal/unix.rs
41
100
tokio-rs/tokio:tokio/src/signal/unix.rs:3
// `libc::c_int` and `std::os::raw::c_int` are currently the same type, and are // unlikely to change to other types, but technically libc can change this // in the future minor version. // See https://github.com/tokio-rs/tokio/issues/3767 for more. pub const fn from_raw(signum: std::os::raw::c_int) -> ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/signal/unix.rs
81
140
tokio-rs/tokio:tokio/src/signal/unix.rs:4
Self(libc::SIGHUP) } /// Represents the `SIGINFO` signal. /// /// On Unix systems this signal is sent to request a status update from the /// process. By default, this signal is ignored. #[cfg(any( target_os = "dragonfly", target_os = "freebsd", target_os = "macos", ...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/signal/unix.rs
121
180
tokio-rs/tokio:tokio/src/signal/unix.rs:5
Self(libc::SIGPIPE) } /// Represents the `SIGQUIT` signal. /// /// On Unix systems this signal is sent to issue a shutdown of the /// process, after which the OS will dump the process core. /// By default, the process is terminated by this signal. pub const fn quit() -> Self { Self(...
rust
rust
rust-source
tokio-rs/tokio
tokio/src/signal/unix.rs
MIT
d4178cf34924d14fca4ecf551c97b8953376f25a
github
async-runtime
https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/signal/unix.rs
161
220