tokio: add support for signals up to SIGRTMAX (#4555)

The POSIX standard not only supports "reliable signals", but also
"real-time signals". This commit adds support for the latter.
This commit is contained in:
weisbrja
2022-03-05 06:33:32 +00:00
committed by GitHub
parent 5b947ca2c7
commit e8ae65a697
2 changed files with 10 additions and 6 deletions
+1 -1
View File
@@ -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]
+9 -5
View File
@@ -22,13 +22,17 @@ 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()
}
}