File tree 2 files changed +58
-2
lines changed
2 files changed +58
-2
lines changed Original file line number Diff line number Diff line change @@ -23,13 +23,25 @@ pub(crate) type OsStorage = Box<[SignalInfo]>;
23
23
impl Init for OsStorage {
24
24
fn init ( ) -> Self {
25
25
// There are reliable signals ranging from 1 to 33 available on every Unix platform.
26
- #[ cfg( not( target_os = "linux" ) ) ]
26
+ #[ cfg( not( any ( target_os = "linux" , target_os = "illumos" ) ) ) ]
27
27
let possible = 0 ..=33 ;
28
28
29
29
// On Linux, there are additional real-time signals available.
30
30
#[ cfg( target_os = "linux" ) ]
31
31
let possible = 0 ..=libc:: SIGRTMAX ( ) ;
32
32
33
+ // On illumos, signal numbers go up to 41 (SIGINFO). The list of signals
34
+ // hasn't changed since 2013. See
35
+ // https://github.com/illumos/illumos-gate/blob/master/usr/src/uts/common/sys/iso/signal_iso.h.
36
+ //
37
+ // illumos also has real-time signals, but this capability isn't exposed
38
+ // by libc as of 0.2.167, so we don't support them at the moment. Once
39
+ // https://github.com/rust-lang/libc/pull/4171 is merged and released in
40
+ // upstream libc, we should switch the illumos impl to do what Linux
41
+ // does.
42
+ #[ cfg( target_os = "illumos" ) ]
43
+ let possible = 0 ..=41 ;
44
+
33
45
possible. map ( |_| SignalInfo :: default ( ) ) . collect ( )
34
46
}
35
47
}
@@ -130,7 +142,8 @@ impl SignalKind {
130
142
target_os = "freebsd" ,
131
143
target_os = "macos" ,
132
144
target_os = "netbsd" ,
133
- target_os = "openbsd"
145
+ target_os = "openbsd" ,
146
+ target_os = "illumos"
134
147
) ) ]
135
148
pub const fn info ( ) -> Self {
136
149
Self ( libc:: SIGINFO )
Original file line number Diff line number Diff line change
1
+ #![ warn( rust_2018_idioms) ]
2
+ #![ cfg( feature = "full" ) ]
3
+ #![ cfg( any(
4
+ target_os = "dragonfly" ,
5
+ target_os = "freebsd" ,
6
+ target_os = "macos" ,
7
+ target_os = "netbsd" ,
8
+ target_os = "openbsd" ,
9
+ target_os = "illumos"
10
+ ) ) ]
11
+ #![ cfg( not( miri) ) ] // No `sigaction` on Miri
12
+
13
+ mod support {
14
+ pub mod signal;
15
+ }
16
+ use support:: signal:: send_signal;
17
+
18
+ use tokio:: signal;
19
+ use tokio:: signal:: unix:: SignalKind ;
20
+ use tokio:: sync:: oneshot;
21
+ use tokio:: time:: { timeout, Duration } ;
22
+
23
+ #[ tokio:: test]
24
+ async fn siginfo ( ) {
25
+ let mut sig = signal:: unix:: signal ( SignalKind :: info ( ) ) . expect ( "installed signal handler" ) ;
26
+
27
+ let ( fire, wait) = oneshot:: channel ( ) ;
28
+
29
+ // NB: simulate a signal coming in by exercising our signal handler
30
+ // to avoid complications with sending SIGINFO to the test process
31
+ tokio:: spawn ( async {
32
+ wait. await . expect ( "wait failed" ) ;
33
+ send_signal ( libc:: SIGINFO ) ;
34
+ } ) ;
35
+
36
+ let _ = fire. send ( ( ) ) ;
37
+
38
+ // Add a timeout to ensure the test doesn't hang.
39
+ timeout ( Duration :: from_secs ( 5 ) , sig. recv ( ) )
40
+ . await
41
+ . expect ( "received SIGINFO signal in time" )
42
+ . expect ( "received SIGINFO signal" ) ;
43
+ }
You can’t perform that action at this time.
0 commit comments