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/unix.rs:6 | 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 {
Self::from_raw(signum as libc::c_int)
}
}
impl From<SignalKind> for std::os::raw::c_int {
fn from(kind: SignalKind) -> 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 | 201 | 260 |
tokio-rs/tokio:tokio/src/signal/unix.rs:7 | /// 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 wakeup, ignore any errors (anything reasonably possible is
// full pipe and then it will wake up anyway).
let mut sender = &globals.s... | 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 | 241 | 300 |
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 to the default reactor.
... | 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 | 361 | 420 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | /// }
/// }
/// ```
pub async fn recv(&mut self) -> Option<()> {
self.inner.recv().await
}
/// Polls to receive the next signal notification event, outside of an
/// `async` context.
///
/// This method returns:
///
/// * `Poll::Pending` if no signals are available ... | 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 | 441 | 500 |
tokio-rs/tokio:tokio/src/signal/unix.rs:13 | /// ```
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(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>>;
}
#[cfg(fe... | 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 | 481 | 532 |
tokio-rs/tokio:tokio/src/signal/unix.rs:14 | #[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 | d4178cf34924d14fca4ecf551c97b8953376f25a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/d4178cf34924d14fca4ecf551c97b8953376f25a/tokio/src/signal/unix.rs | 521 | 532 |
tokio-rs/tokio:tokio/src/signal/unix.rs:7 | /// 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 wakeup, ignore any errors (anything reasonably possible is
// full pipe and then it will wake up anyway).
let mut sender = &globals.s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 09bc9a05e4f3da8135add5947682edb48279d0b0 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/09bc9a05e4f3da8135add5947682edb48279d0b0/tokio/src/signal/unix.rs | 241 | 300 |
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 | 2a0df5fb05ae1a624fe2f6db756190f41812214b | github | async-runtime | https://github.com/tokio-rs/tokio/blob/2a0df5fb05ae1a624fe2f6db756190f41812214b/tokio/src/signal/unix.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | /// }
/// }
/// ```
pub async fn recv(&mut self) -> Option<()> {
self.inner.recv().await
}
/// Polls to receive the next signal notification event, outside of an
/// `async` context.
///
/// This method returns:
///
/// * `Poll::Pending` if no signals are available ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/signal/unix.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/signal/unix.rs:13 | /// ```
pub fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> {
self.inner.poll_recv(cx)
}
}
// Work around for abstracting streams internally
pub(crate) trait InternalStream {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>>;
}
impl InternalStream for Signal {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 131e7b4e49c8849298ba54b4e0c99f4b81d869e3 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/131e7b4e49c8849298ba54b4e0c99f4b81d869e3/tokio/src/signal/unix.rs | 481 | 530 |
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 | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/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 | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/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 | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/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(li... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 6871084629ad95c37c7136d865890ab2e371ea12 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6871084629ad95c37c7136d865890ab2e371ea12/tokio/src/signal/unix.rs | 161 | 220 |
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 | e23c6f3935b550ddb7587232c423145e06087551 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e23c6f3935b550ddb7587232c423145e06087551/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 | e23c6f3935b550ddb7587232c423145e06087551 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e23c6f3935b550ddb7587232c423145e06087551/tokio/src/signal/unix.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/signal/unix.rs:6 | 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 {
Self::from_raw(signum as libc::c_int)
}
}
impl From<SignalKind> for std::os::raw::c_int {
fn from(kind: SignalKind) -> Self {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e23c6f3935b550ddb7587232c423145e06087551 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e23c6f3935b550ddb7587232c423145e06087551/tokio/src/signal/unix.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/signal/unix.rs:7 | /// 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 wakeup, ignore any errors (anything reasonably possible is
// full pipe and then it will wake up anyway).
let mut sender = &globals.s... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | b9ae7e6659f31508fbe81e29508984d0c6f2d0b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b9ae7e6659f31508fbe81e29508984d0c6f2d0b4/tokio/src/signal/unix.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/signal/unix.rs:10 | }
/// Creates a new stream which will receive notifications when the current
/// process receives the specified signal `kind`.
///
/// This function will create a new stream which binds to the default reactor.
/// The `Signal` stream is an infinite stream which will receive
/// notifications whenever a signal is recei... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | b9ae7e6659f31508fbe81e29508984d0c6f2d0b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b9ae7e6659f31508fbe81e29508984d0c6f2d0b4/tokio/src/signal/unix.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | self.inner.recv().await
}
/// Polls to receive the next signal notification event, outside of an
/// `async` context.
///
/// This method returns:
///
/// * `Poll::Pending` if no signals are available but the channel is not
/// closed.
/// * `Poll::Ready(Some(()))` if a signal ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | b9ae7e6659f31508fbe81e29508984d0c6f2d0b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b9ae7e6659f31508fbe81e29508984d0c6f2d0b4/tokio/src/signal/unix.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/signal/unix.rs:13 | }
// Work around for abstracting streams internally
pub(crate) trait InternalStream {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>>;
}
impl InternalStream for Signal {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> {
self.poll_recv(cx)
}
}
pub(crate) fn ctrl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | b9ae7e6659f31508fbe81e29508984d0c6f2d0b4 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b9ae7e6659f31508fbe81e29508984d0c6f2d0b4/tokio/src/signal/unix.rs | 481 | 526 |
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 | 6c19748f901a1b8cd7fbf84650f1647342b5a66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c19748f901a1b8cd7fbf84650f1647342b5a66e/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 | 6c19748f901a1b8cd7fbf84650f1647342b5a66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c19748f901a1b8cd7fbf84650f1647342b5a66e/tokio/src/signal/unix.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/signal/unix.rs:3 | // 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://github.com/tokio-rs/tokio/issues/3767 for more.
pub const fn from_raw(sig... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 6c19748f901a1b8cd7fbf84650f1647342b5a66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c19748f901a1b8cd7fbf84650f1647342b5a66e/tokio/src/signal/unix.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/signal/unix.rs:4 | 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(any(
target_os = "dragonfly",
target_os = "freeb... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 6c19748f901a1b8cd7fbf84650f1647342b5a66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c19748f901a1b8cd7fbf84650f1647342b5a66e/tokio/src/signal/unix.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/signal/unix.rs:5 | 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 OS will dump the process core.
/// By default, the process is terminated by this signal.
pub con... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 6c19748f901a1b8cd7fbf84650f1647342b5a66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c19748f901a1b8cd7fbf84650f1647342b5a66e/tokio/src/signal/unix.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/signal/unix.rs:6 | /// 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 {
Self::from_raw(signum as libc::c_int)
}
}
impl From<SignalKind> for std::os::raw::c_int... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 6c19748f901a1b8cd7fbf84650f1647342b5a66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c19748f901a1b8cd7fbf84650f1647342b5a66e/tokio/src/signal/unix.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/signal/unix.rs:7 | ///
/// Those two operations should both be async-signal safe.
fn action(globals: Pin<&'static Globals>, signal: libc::c_int) {
globals.record_event(signal as EventId);
// Send a wakeup, ignore any errors (anything reasonably possible is
// full pipe and then it will wake up anyway).
let mut sender = &... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 6c19748f901a1b8cd7fbf84650f1647342b5a66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c19748f901a1b8cd7fbf84650f1647342b5a66e/tokio/src/signal/unix.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/signal/unix.rs:10 | inner: RxFuture,
}
/// Creates a new stream which will receive notifications when the current
/// process receives the specified signal `kind`.
///
/// This function will create a new stream which binds to the default reactor.
/// The `Signal` stream is an infinite stream which will receive
/// notifications whenever ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 6c19748f901a1b8cd7fbf84650f1647342b5a66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c19748f901a1b8cd7fbf84650f1647342b5a66e/tokio/src/signal/unix.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | pub async fn recv(&mut self) -> Option<()> {
self.inner.recv().await
}
/// Polls to receive the next signal notification event, outside of an
/// `async` context.
///
/// This method returns:
///
/// * `Poll::Pending` if no signals are available but the channel is not
/// cl... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 6c19748f901a1b8cd7fbf84650f1647342b5a66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c19748f901a1b8cd7fbf84650f1647342b5a66e/tokio/src/signal/unix.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/signal/unix.rs:13 | }
}
// Work around for abstracting streams internally
pub(crate) trait InternalStream {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>>;
}
impl InternalStream for Signal {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> {
self.poll_recv(cx)
}
}
pub(crate) fn ct... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 6c19748f901a1b8cd7fbf84650f1647342b5a66e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/6c19748f901a1b8cd7fbf84650f1647342b5a66e/tokio/src/signal/unix.rs | 481 | 527 |
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::signal::Handle;
use crate::signal::regis... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 1ca17bef67677ffcd447f4dce2dd49099fe67e0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1ca17bef67677ffcd447f4dce2dd49099fe67e0a/tokio/src/signal/unix.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/signal/unix.rs:6 | 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 {
Self::from_raw(signum as libc::c_int)
}
}
impl From<SignalKind> for std::os::raw::c_int {
fn from(kind: SignalKind) -> Self {
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 1ca17bef67677ffcd447f4dce2dd49099fe67e0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1ca17bef67677ffcd447f4dce2dd49099fe67e0a/tokio/src/signal/unix.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/signal/unix.rs:7 | /// Those two operations should both be async-signal safe.
fn action(globals: Pin<&'static Globals>, signal: libc::c_int) {
globals.record_event(signal as EventId);
// Send a wakeup, ignore any errors (anything reasonably possible is
// full pipe and then it will wake up anyway).
let mut sender = &glob... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 1ca17bef67677ffcd447f4dce2dd49099fe67e0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1ca17bef67677ffcd447f4dce2dd49099fe67e0a/tokio/src/signal/unix.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/signal/unix.rs:10 | }
/// Creates a new stream which will receive notifications when the current
/// process receives the specified signal `kind`.
///
/// This function will create a new stream which binds to the default reactor.
/// The `Signal` stream is an infinite stream which will receive
/// notifications whenever a signal is recei... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 1ca17bef67677ffcd447f4dce2dd49099fe67e0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1ca17bef67677ffcd447f4dce2dd49099fe67e0a/tokio/src/signal/unix.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | }
/// Polls to receive the next signal notification event, outside of an
/// `async` context.
///
/// This method returns:
///
/// * `Poll::Pending` if no signals are available but the channel is not
/// closed.
/// * `Poll::Ready(Some(()))` if a signal is available.
/// * `Po... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 1ca17bef67677ffcd447f4dce2dd49099fe67e0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1ca17bef67677ffcd447f4dce2dd49099fe67e0a/tokio/src/signal/unix.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/signal/unix.rs:13 | // Work around for abstracting streams internally
pub(crate) trait InternalStream {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>>;
}
impl InternalStream for Signal {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> {
self.poll_recv(cx)
}
}
pub(crate) fn ctrl_c(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 1ca17bef67677ffcd447f4dce2dd49099fe67e0a | github | async-runtime | https://github.com/tokio-rs/tokio/blob/1ca17bef67677ffcd447f4dce2dd49099fe67e0a/tokio/src/signal/unix.rs | 481 | 525 |
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::signal::registry::{globals, EventId, EventInfo, G... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | ba93b2803303df515eded0ff2099bb5df693a7c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ba93b2803303df515eded0ff2099bb5df693a7c9/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,
receiver: UnixStream,
}
impl Init for OsExt... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | ba93b2803303df515eded0ff2099bb5df693a7c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ba93b2803303df515eded0ff2099bb5df693a7c9/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 | ba93b2803303df515eded0ff2099bb5df693a7c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ba93b2803303df515eded0ff2099bb5df693a7c9/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(an... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | ba93b2803303df515eded0ff2099bb5df693a7c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ba93b2803303df515eded0ff2099bb5df693a7c9/tokio/src/signal/unix.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/signal/unix.rs:5 | /// 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 OS will dump the process core.
/// By default, the process is terminated by thi... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | ba93b2803303df515eded0ff2099bb5df693a7c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ba93b2803303df515eded0ff2099bb5df693a7c9/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 {
Self::from_... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | ba93b2803303df515eded0ff2099bb5df693a7c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ba93b2803303df515eded0ff2099bb5df693a7c9/tokio/src/signal/unix.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/signal/unix.rs:7 | /// 2. Wake up the driver by writing a byte to a pipe
///
/// Those two operations should both be async-signal safe.
fn action(globals: Pin<&'static Globals>, signal: libc::c_int) {
globals.record_event(signal as EventId);
// Send a wakeup, ignore any errors (anything reasonably possible is
// full pipe an... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | ba93b2803303df515eded0ff2099bb5df693a7c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ba93b2803303df515eded0ff2099bb5df693a7c9/tokio/src/signal/unix.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/signal/unix.rs:10 | pub struct Signal {
inner: RxFuture,
}
/// Creates a new stream which will receive notifications when the current
/// process receives the specified signal `kind`.
///
/// This function will create a new stream which binds to the default reactor.
/// The `Signal` stream is an infinite stream which will receive
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | ba93b2803303df515eded0ff2099bb5df693a7c9 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/ba93b2803303df515eded0ff2099bb5df693a7c9/tokio/src/signal/unix.rs | 361 | 420 |
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,
receiver: UnixStream,
}
impl Init for OsExt... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 18efef7d3b926750c0b026a401e85e723f401854 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18efef7d3b926750c0b026a401e85e723f401854/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 | 18efef7d3b926750c0b026a401e85e723f401854 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18efef7d3b926750c0b026a401e85e723f401854/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 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(any(
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 18efef7d3b926750c0b026a401e85e723f401854 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18efef7d3b926750c0b026a401e85e723f401854/tokio/src/signal/unix.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/signal/unix.rs:5 | /// this signal.
pub 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 OS will dump the process core.
/// By default, the process is terminated by this sign... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 18efef7d3b926750c0b026a401e85e723f401854 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18efef7d3b926750c0b026a401e85e723f401854/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 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 {
Self::from_raw(si... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 18efef7d3b926750c0b026a401e85e723f401854 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/18efef7d3b926750c0b026a401e85e723f401854/tokio/src/signal/unix.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/signal/unix.rs:10 | pub struct Signal {
inner: RxFuture,
}
/// Creates a new stream which will receive notifications when the current
/// process receives the specified signal `kind`.
///
/// This function will create a new stream which binds to the default reactor.
/// The `Signal` stream is an infinite stream which will receive
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | b4d82c3e70a63d2ca59de813b9f106d6b4af7db5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b4d82c3e70a63d2ca59de813b9f106d6b4af7db5/tokio/src/signal/unix.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | ///
/// This method returns:
///
/// * `Poll::Pending` if no signals are available but the channel is not
/// closed.
/// * `Poll::Ready(Some(()))` if a signal is available.
/// * `Poll::Ready(None)` if the channel has been closed and all signals
/// sent before it was closed have b... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | b4d82c3e70a63d2ca59de813b9f106d6b4af7db5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b4d82c3e70a63d2ca59de813b9f106d6b4af7db5/tokio/src/signal/unix.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/signal/unix.rs:13 | }
impl InternalStream for Signal {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> {
self.poll_recv(cx)
}
}
pub(crate) fn ctrl_c() -> io::Result<Signal> {
signal(SignalKind::interrupt())
}
#[cfg(all(test, not(loom)))]
mod tests {
use super::*;
#[test]
fn signal_enab... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | b4d82c3e70a63d2ca59de813b9f106d6b4af7db5 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/b4d82c3e70a63d2ca59de813b9f106d6b4af7db5/tokio/src/signal/unix.rs | 481 | 521 |
tokio-rs/tokio:tokio/src/signal/unix.rs:10 | pub struct Signal {
inner: RxFuture,
}
/// Creates a new stream which will receive notifications when the current
/// process receives the specified signal `kind`.
///
/// This function will create a new stream which binds to the default reactor.
/// The `Signal` stream is an infinite stream which will receive
///... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e8ae65a697d04aa11d5587c45caf999cb3b7f36e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e8ae65a697d04aa11d5587c45caf999cb3b7f36e/tokio/src/signal/unix.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | /// * `Poll::Ready(None)` if the channel has been closed and all signals
/// 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 ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e8ae65a697d04aa11d5587c45caf999cb3b7f36e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e8ae65a697d04aa11d5587c45caf999cb3b7f36e/tokio/src/signal/unix.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/signal/unix.rs:13 | }
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() {
signal_enable(SignalKind::from_raw(-1), &Handle::default()).unwrap_err();
}
#[test]
fn sig... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e8ae65a697d04aa11d5587c45caf999cb3b7f36e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e8ae65a697d04aa11d5587c45caf999cb3b7f36e/tokio/src/signal/unix.rs | 481 | 515 |
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::signal::registry::{globals, EventId, EventInfo, G... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 3dd5a0d3bb0664490ae04be937c8a1160a5f7960 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3dd5a0d3bb0664490ae04be937c8a1160a5f7960/tokio/src/signal/unix.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/signal/unix.rs:2 | where
F: FnMut(&'a EventInfo),
{
self.iter().map(|si| &si.event_info).for_each(f)
}
}
#[derive(Debug)]
pub(crate) struct OsExtraData {
sender: UnixStream,
receiver: UnixStream,
}
impl Init for OsExtraData {
fn init() -> Self {
let (receiver, sender) = UnixStream::pair().exp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 3dd5a0d3bb0664490ae04be937c8a1160a5f7960 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3dd5a0d3bb0664490ae04be937c8a1160a5f7960/tokio/src/signal/unix.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/signal/unix.rs:3 | // in the future minor version.
// See https://github.com/tokio-rs/tokio/issues/3767 for more.
pub fn from_raw(signum: std::os::raw::c_int) -> Self {
Self(signum as libc::c_int)
}
/// Get the signal's numeric value.
///
/// ```rust
/// # use tokio::signal::unix::SignalKind;
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 3dd5a0d3bb0664490ae04be937c8a1160a5f7960 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3dd5a0d3bb0664490ae04be937c8a1160a5f7960/tokio/src/signal/unix.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/signal/unix.rs:4 | /// 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",
target_os = "netbsd",
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 3dd5a0d3bb0664490ae04be937c8a1160a5f7960 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3dd5a0d3bb0664490ae04be937c8a1160a5f7960/tokio/src/signal/unix.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/signal/unix.rs:5 | /// 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 fn quit() -> Self {
Self(libc::SIGQUIT)
}
/// Represent... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 3dd5a0d3bb0664490ae04be937c8a1160a5f7960 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3dd5a0d3bb0664490ae04be937c8a1160a5f7960/tokio/src/signal/unix.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/signal/unix.rs:6 | }
}
impl From<std::os::raw::c_int> for SignalKind {
fn from(signum: std::os::raw::c_int) -> Self {
Self::from_raw(signum as libc::c_int)
}
}
impl From<SignalKind> for std::os::raw::c_int {
fn from(kind: SignalKind) -> Self {
kind.as_raw_value()
}
}
pub(crate) struct SignalInfo {
e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 3dd5a0d3bb0664490ae04be937c8a1160a5f7960 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3dd5a0d3bb0664490ae04be937c8a1160a5f7960/tokio/src/signal/unix.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/signal/unix.rs:7 | globals.record_event(signal as EventId);
// Send a wakeup, ignore any errors (anything reasonably possible is
// full pipe and then it will wake up anyway).
let mut sender = &globals.sender;
drop(sender.write(&[1]));
}
/// Enables this module to receive signal notifications for the `signal`
/// provid... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 3dd5a0d3bb0664490ae04be937c8a1160a5f7960 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3dd5a0d3bb0664490ae04be937c8a1160a5f7960/tokio/src/signal/unix.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/signal/unix.rs:10 | /// Creates a new stream which will receive notifications when the current
/// process receives the specified signal `kind`.
///
/// This function will create a new stream which binds to the default reactor.
/// The `Signal` stream is an infinite stream which will receive
/// notifications whenever a signal is received... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 3dd5a0d3bb0664490ae04be937c8a1160a5f7960 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3dd5a0d3bb0664490ae04be937c8a1160a5f7960/tokio/src/signal/unix.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | ///
/// 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;
///
/// struct MyFuture {
/// signal: Signal,
/// }
///
/// impl ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 3dd5a0d3bb0664490ae04be937c8a1160a5f7960 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3dd5a0d3bb0664490ae04be937c8a1160a5f7960/tokio/src/signal/unix.rs | 441 | 500 |
tokio-rs/tokio:tokio/src/signal/unix.rs:13 | }
#[cfg(all(test, not(loom)))]
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:... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 3dd5a0d3bb0664490ae04be937c8a1160a5f7960 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/3dd5a0d3bb0664490ae04be937c8a1160a5f7960/tokio/src/signal/unix.rs | 481 | 511 |
tokio-rs/tokio:tokio/src/signal/unix.rs:2 | where
F: FnMut(&'a EventInfo),
{
self.iter().map(|si| &si.event_info).for_each(f)
}
}
#[derive(Debug)]
pub(crate) struct OsExtraData {
sender: UnixStream,
receiver: UnixStream,
}
impl Init for OsExtraData {
fn init() -> Self {
let (receiver, sender) = UnixStream::pair().exp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 69a6585429d17701a87aa914500d9c11e88c663f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69a6585429d17701a87aa914500d9c11e88c663f/tokio/src/signal/unix.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/signal/unix.rs:3 | // in the future minor version.
// See https://github.com/tokio-rs/tokio/issues/3767 for more.
pub fn from_raw(signum: std::os::raw::c_int) -> Self {
Self(signum as libc::c_int)
}
/// Represents the SIGALRM signal.
///
/// On Unix systems this signal is sent when a real-time timer has e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 69a6585429d17701a87aa914500d9c11e88c663f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69a6585429d17701a87aa914500d9c11e88c663f/tokio/src/signal/unix.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/signal/unix.rs:4 | ))]
pub fn info() -> Self {
Self(libc::SIGINFO)
}
/// Represents the SIGINT signal.
///
/// On Unix systems this signal is sent to interrupt a program.
/// By default, the process is terminated by this signal.
pub fn interrupt() -> Self {
Self(libc::SIGINT)
}
/// Re... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 69a6585429d17701a87aa914500d9c11e88c663f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69a6585429d17701a87aa914500d9c11e88c663f/tokio/src/signal/unix.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/signal/unix.rs:5 | ///
/// On Unix systems this signal is sent to issue a shutdown of the
/// process. By default, the process is terminated by this signal.
pub fn terminate() -> Self {
Self(libc::SIGTERM)
}
/// Represents the SIGUSR1 signal.
///
/// On Unix systems this is a user defined signal.
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 69a6585429d17701a87aa914500d9c11e88c663f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69a6585429d17701a87aa914500d9c11e88c663f/tokio/src/signal/unix.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/signal/unix.rs:6 | SignalInfo {
event_info: Default::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 primarily:
///
/// 1. Flag that our specif... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 69a6585429d17701a87aa914500d9c11e88c663f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69a6585429d17701a87aa914500d9c11e88c663f/tokio/src/signal/unix.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/signal/unix.rs:7 | 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(());
siginfo.init.call_once(|| {
regist... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 69a6585429d17701a87aa914500d9c11e88c663f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69a6585429d17701a87aa914500d9c11e88c663f/tokio/src/signal/unix.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/signal/unix.rs:9 | /// 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!("got signal HUP");
/// ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 69a6585429d17701a87aa914500d9c11e88c663f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69a6585429d17701a87aa914500d9c11e88c663f/tokio/src/signal/unix.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/signal/unix.rs:10 | let rx = signal_with_handle(kind, &Handle::current())?;
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, han... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 69a6585429d17701a87aa914500d9c11e88c663f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69a6585429d17701a87aa914500d9c11e88c663f/tokio/src/signal/unix.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/signal/unix.rs:11 | /// ```
pub async fn recv(&mut self) -> Option<()> {
self.inner.recv().await
}
/// Polls to receive the next signal notification event, outside of an
/// `async` context.
///
/// This method returns:
///
/// * `Poll::Pending` if no signals are available but the channel is not
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 69a6585429d17701a87aa914500d9c11e88c663f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69a6585429d17701a87aa914500d9c11e88c663f/tokio/src/signal/unix.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | self.inner.poll_recv(cx)
}
}
// Work around for abstracting streams internally
pub(crate) trait InternalStream {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>>;
}
impl InternalStream for Signal {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> {
self.poll_recv(... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 69a6585429d17701a87aa914500d9c11e88c663f | github | async-runtime | https://github.com/tokio-rs/tokio/blob/69a6585429d17701a87aa914500d9c11e88c663f/tokio/src/signal/unix.rs | 441 | 477 |
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)]
use crate::signal::registry::{globals, EventId, EventInfo, Globals, Init, Storage};
use crate::signal::RxFuture;
use crate... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e188e99ca3bae5fe9a3e8622b59094388259cd84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e188e99ca3bae5fe9a3e8622b59094388259cd84/tokio/src/signal/unix.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/signal/unix.rs:2 | F: FnMut(&'a EventInfo),
{
self.iter().map(|si| &si.event_info).for_each(f)
}
}
#[derive(Debug)]
pub(crate) struct OsExtraData {
sender: UnixStream,
receiver: UnixStream,
}
impl Init for OsExtraData {
fn init() -> Self {
let (receiver, sender) = UnixStream::pair().expect("failed to... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e188e99ca3bae5fe9a3e8622b59094388259cd84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e188e99ca3bae5fe9a3e8622b59094388259cd84/tokio/src/signal/unix.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/signal/unix.rs:3 | // See https://github.com/tokio-rs/tokio/issues/3767 for more.
pub fn from_raw(signum: std::os::raw::c_int) -> Self {
Self(signum as libc::c_int)
}
/// Represents the SIGALRM signal.
///
/// On Unix systems this signal is sent when a real-time timer has expired.
/// By default, the proc... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e188e99ca3bae5fe9a3e8622b59094388259cd84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e188e99ca3bae5fe9a3e8622b59094388259cd84/tokio/src/signal/unix.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/signal/unix.rs:4 | pub fn info() -> Self {
Self(libc::SIGINFO)
}
/// Represents the SIGINT signal.
///
/// On Unix systems this signal is sent to interrupt a program.
/// By default, the process is terminated by this signal.
pub fn interrupt() -> Self {
Self(libc::SIGINT)
}
/// Represents... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e188e99ca3bae5fe9a3e8622b59094388259cd84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e188e99ca3bae5fe9a3e8622b59094388259cd84/tokio/src/signal/unix.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/signal/unix.rs:5 | /// On Unix systems this signal is sent to issue a shutdown of the
/// process. By default, the process is terminated by this signal.
pub fn terminate() -> Self {
Self(libc::SIGTERM)
}
/// Represents the SIGUSR1 signal.
///
/// On Unix systems this is a user defined signal.
/// By d... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e188e99ca3bae5fe9a3e8622b59094388259cd84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e188e99ca3bae5fe9a3e8622b59094388259cd84/tokio/src/signal/unix.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/signal/unix.rs:6 | event_info: Default::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 primarily:
///
/// 1. Flag that our specific signal was received (e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e188e99ca3bae5fe9a3e8622b59094388259cd84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e188e99ca3bae5fe9a3e8622b59094388259cd84/tokio/src/signal/unix.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/signal/unix.rs:7 | 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 | e188e99ca3bae5fe9a3e8622b59094388259cd84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e188e99ca3bae5fe9a3e8622b59094388259cd84/tokio/src/signal/unix.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/signal/unix.rs:9 | /// // An infinite stream of hangup signals.
/// let mut stream = signal(SignalKind::hangup())?;
///
/// // Print whenever a HUP signal is received
/// loop {
/// stream.recv().await;
/// println!("got signal HUP");
/// }
/// }
/// ```
#[must_use = "streams do nothing unless polled"]... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e188e99ca3bae5fe9a3e8622b59094388259cd84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e188e99ca3bae5fe9a3e8622b59094388259cd84/tokio/src/signal/unix.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/signal/unix.rs:10 | 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 | e188e99ca3bae5fe9a3e8622b59094388259cd84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e188e99ca3bae5fe9a3e8622b59094388259cd84/tokio/src/signal/unix.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | }
}
// Work around for abstracting streams internally
pub(crate) trait InternalStream {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>>;
}
impl InternalStream for Signal {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> {
self.poll_recv(cx)
}
}
pub(crate) fn ct... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e188e99ca3bae5fe9a3e8622b59094388259cd84 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e188e99ca3bae5fe9a3e8622b59094388259cd84/tokio/src/signal/unix.rs | 441 | 476 |
tokio-rs/tokio:tokio/src/signal/unix.rs:6 | event_info: Default::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 primarily:
///
/// 1. Flag that our specific signal was received (e... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 7207e3ca43d27b5e86d5b10a2425c6aae87b8ee1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7207e3ca43d27b5e86d5b10a2425c6aae87b8ee1/tokio/src/signal/unix.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/signal/unix.rs:9 | /// // An infinite stream of hangup signals.
/// let mut stream = signal(SignalKind::hangup())?;
///
/// // Print whenever a HUP signal is received
/// loop {
/// stream.recv().await;
/// println!("got signal HUP");
/// }
/// }
/// ```
#[must_use = "streams do nothing unless polled"]... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 7207e3ca43d27b5e86d5b10a2425c6aae87b8ee1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7207e3ca43d27b5e86d5b10a2425c6aae87b8ee1/tokio/src/signal/unix.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/signal/unix.rs:10 | 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 | 7207e3ca43d27b5e86d5b10a2425c6aae87b8ee1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7207e3ca43d27b5e86d5b10a2425c6aae87b8ee1/tokio/src/signal/unix.rs | 361 | 420 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | }
}
// Work around for abstracting streams internally
pub(crate) trait InternalStream {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>>;
}
impl InternalStream for Signal {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> {
self.poll_recv(cx)
}
}
pub(crate) fn ct... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | 7207e3ca43d27b5e86d5b10a2425c6aae87b8ee1 | github | async-runtime | https://github.com/tokio-rs/tokio/blob/7207e3ca43d27b5e86d5b10a2425c6aae87b8ee1/tokio/src/signal/unix.rs | 441 | 476 |
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)]
use crate::signal::registry::{globals, EventId, EventInfo, Globals, Init, Storage};
use crate::signal::RxFuture;
use crate... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e4f76688a00fa2ce81ab6c074700995095c29e1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/unix.rs | 1 | 60 |
tokio-rs/tokio:tokio/src/signal/unix.rs:2 | where
F: FnMut(&'a EventInfo),
{
self.iter().map(|si| &si.event_info).for_each(f)
}
}
#[derive(Debug)]
pub(crate) struct OsExtraData {
sender: UnixStream,
receiver: UnixStream,
}
impl Init for OsExtraData {
fn init() -> Self {
let (receiver, sender) = UnixStream::pair().exp... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e4f76688a00fa2ce81ab6c074700995095c29e1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/unix.rs | 41 | 100 |
tokio-rs/tokio:tokio/src/signal/unix.rs:3 | /// Represents the SIGALRM signal.
///
/// On Unix systems this signal is sent when a real-time timer has expired.
/// By default, the process is terminated by this signal.
pub fn alarm() -> Self {
Self(libc::SIGALRM)
}
/// Represents the SIGCHLD signal.
///
/// On Unix systems ... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e4f76688a00fa2ce81ab6c074700995095c29e1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/unix.rs | 81 | 140 |
tokio-rs/tokio:tokio/src/signal/unix.rs:4 | ///
/// On Unix systems this signal is sent to interrupt a program.
/// By default, the process is terminated by this signal.
pub fn interrupt() -> Self {
Self(libc::SIGINT)
}
/// Represents the SIGIO signal.
///
/// On Unix systems this signal is sent when I/O operations are possib... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e4f76688a00fa2ce81ab6c074700995095c29e1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/unix.rs | 121 | 180 |
tokio-rs/tokio:tokio/src/signal/unix.rs:5 | /// Represents the SIGUSR1 signal.
///
/// On Unix systems this is a user defined signal.
/// By default, the process is terminated by this signal.
pub fn user_defined1() -> Self {
Self(libc::SIGUSR1)
}
/// Represents the SIGUSR2 signal.
///
/// On Unix systems this is a user de... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e4f76688a00fa2ce81ab6c074700995095c29e1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/unix.rs | 161 | 220 |
tokio-rs/tokio:tokio/src/signal/unix.rs:6 | }
/// 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 pipe
///
/// Those two operations should both be asyn... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e4f76688a00fa2ce81ab6c074700995095c29e1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/unix.rs | 201 | 260 |
tokio-rs/tokio:tokio/src/signal/unix.rs:7 | };
let mut registered = Ok(());
siginfo.init.call_once(|| {
registered = unsafe {
signal_hook_registry::register(signal, move || action(globals, signal)).map(|_| ())
};
if registered.is_ok() {
siginfo.initialized.store(true, Ordering::Relaxed);
}
});
... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e4f76688a00fa2ce81ab6c074700995095c29e1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/unix.rs | 241 | 300 |
tokio-rs/tokio:tokio/src/signal/unix.rs:9 | /// stream.recv().await;
/// println!("got signal HUP");
/// }
/// }
/// ```
#[must_use = "streams do nothing unless polled"]
#[derive(Debug)]
pub struct Signal {
inner: RxFuture,
}
/// Creates a new stream which will receive notifications when the current
/// process receives the specified sig... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e4f76688a00fa2ce81ab6c074700995095c29e1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/unix.rs | 321 | 380 |
tokio-rs/tokio:tokio/src/signal/unix.rs:11 | /// `async` context.
///
/// This method returns:
///
/// * `Poll::Pending` if no signals are available but the channel is not
/// closed.
/// * `Poll::Ready(Some(()))` if a signal is available.
/// * `Poll::Ready(None)` if the channel has been closed and all signals
/// sent be... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e4f76688a00fa2ce81ab6c074700995095c29e1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/unix.rs | 401 | 460 |
tokio-rs/tokio:tokio/src/signal/unix.rs:12 | fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>>;
}
impl InternalStream for Signal {
fn poll_recv(&mut self, cx: &mut Context<'_>) -> Poll<Option<()>> {
self.poll_recv(cx)
}
}
pub(crate) fn ctrl_c() -> io::Result<Signal> {
signal(SignalKind::interrupt())
}
#[cfg(all(test, not(loo... | rust | rust | rust-source | tokio-rs/tokio | tokio/src/signal/unix.rs | MIT | e4f76688a00fa2ce81ab6c074700995095c29e1e | github | async-runtime | https://github.com/tokio-rs/tokio/blob/e4f76688a00fa2ce81ab6c074700995095c29e1e/tokio/src/signal/unix.rs | 441 | 471 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.