Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tokio: add support for signals up to SIGRTMAX #4555

Merged
merged 4 commits into from Mar 5, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion tokio/src/signal/registry.rs
Expand Up @@ -237,7 +237,7 @@ mod tests {
#[test]
fn record_invalid_event_does_nothing() {
let registry = Registry::new(vec![EventInfo::default()]);
registry.record_event(42);
registry.record_event(1302);
}

#[test]
Expand Down
16 changes: 11 additions & 5 deletions tokio/src/signal/unix.rs
Expand Up @@ -22,13 +22,19 @@ use self::driver::Handle;

pub(crate) type OsStorage = Vec<SignalInfo>;

// Number of different unix signals
// (FreeBSD has 33)
const SIGNUM: usize = 33;

impl Init for OsStorage {
fn init() -> Self {
(0..SIGNUM).map(|_| SignalInfo::default()).collect()
// There are reliable signals ranging from 1 to 33 available on every Unix platform.
#[cfg(not(target_os = "linux"))]
let possible = 0..=33;

// On Linux, there are additional real-time signals available.
#[cfg(target_os = "linux")]
let possible = 0..=libc::SIGRTMAX();

possible
.map(|_| SignalInfo::default())
.collect()
}
}

Expand Down