@@ -77,19 +77,76 @@ impl SignalSet {
77
77
78
78
/// Creates a new set of signals that result in process termination.
79
79
///
80
- /// The included signals are only those that can be gracefully handled.
80
+ /// This only includes signals that can be trivially handled with grace:
81
+ /// - [`alarm`](#method.alarm)
82
+ /// - [`hangup`](#method.hangup)
83
+ /// - [`interrupt`](#method.interrupt)
84
+ /// - [`pipe`](#method.pipe)
85
+ /// - [`quit`](#method.quit)
86
+ /// - [`terminate`](#method.terminate)
87
+ /// - [`user_defined_1`](#method.user_defined_1)
88
+ /// - [`user_defined_2`](#method.user_defined_2)
89
+ ///
90
+ /// If a listed signal is not available for the current target, the returned
91
+ /// set will simply not include it.
81
92
#[ inline]
82
93
#[ must_use]
83
94
pub const fn termination ( ) -> Self {
84
- Self :: new ( )
85
- . alarm ( )
86
- . hangup ( )
87
- . interrupt ( )
88
- . pipe ( )
89
- . quit ( )
90
- . terminate ( )
91
- . user_defined_1 ( )
92
- . user_defined_2 ( )
95
+ #[ allow( unused_mut) ]
96
+ let mut set = Self :: new ( ) ;
97
+
98
+ // This would make for an amazing use case of `#[cfg(accessible(...))]`.
99
+ // See https://github.com/rust-lang/rust/issues/64797 for info on this.
100
+ #[ cfg( any(
101
+ // According to `libc`:
102
+ // "bsd"
103
+ target_os = "macos" ,
104
+ target_os = "ios" ,
105
+ target_os = "freebsd" ,
106
+ target_os = "dragonfly" ,
107
+ target_os = "openbsd" ,
108
+ target_os = "netbsd" ,
109
+ // "linux-like"
110
+ target_os = "linux" ,
111
+ target_os = "android" ,
112
+ target_os = "emscripten" ,
113
+ // "solarish"
114
+ target_os = "solaris" ,
115
+ target_os = "illumos" ,
116
+ // Uncategorized
117
+ windows,
118
+ target_os = "fuchsia" ,
119
+ target_os = "redox" ,
120
+ target_os = "haiku" ,
121
+ target_os = "hermit" ,
122
+ target_os = "vxworks" ,
123
+ target_env = "uclibc" ,
124
+ ) ) ]
125
+ {
126
+ #[ cfg( not( windows) ) ]
127
+ {
128
+ set = set. alarm ( ) . hangup ( ) . pipe ( ) . quit ( ) ;
129
+ }
130
+
131
+ #[ cfg( any(
132
+ not( target_env = "uclibc" ) ,
133
+ all(
134
+ target_env = "uclibc" ,
135
+ any(
136
+ target_arch = "arm" ,
137
+ target_arch = "mips" ,
138
+ target_arch = "mips64" ,
139
+ ) ,
140
+ ) ,
141
+ ) ) ]
142
+ {
143
+ set = set. user_defined_1 ( ) . user_defined_2 ( ) ;
144
+ }
145
+
146
+ set = set. interrupt ( ) . terminate ( ) ;
147
+ }
148
+
149
+ set
93
150
}
94
151
95
152
/// Converts `self` into a raw signal set.
0 commit comments