@@ -36,6 +36,8 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
3636 // Hence, we set SIGPIPE to ignore when the program starts up in order
3737 // to prevent this problem. Use `-Zon-broken-pipe=...` to alter this
3838 // behavior.
39+ //
40+ // FIXME: Explain how to use `eii`
3941 reset_sigpipe ( sigpipe) ;
4042
4143 stack_overflow:: init ( ) ;
@@ -156,25 +158,12 @@ pub unsafe fn init(argc: isize, argv: *const *const u8, sigpipe: u8) {
156158 target_vendor = "unikraft" ,
157159 ) ) ) ]
158160 {
159- // We don't want to add this as a public type to std, nor do we
160- // want to `include!` a file from the compiler (which would break
161- // Miri and xargo for example), so we choose to duplicate these
162- // constants from `compiler/rustc_session/src/config/sigpipe.rs`.
163- // See the other file for docs. NOTE: Make sure to keep them in
164- // sync!
165- mod sigpipe {
166- pub const DEFAULT : u8 = 0 ;
167- pub const INHERIT : u8 = 1 ;
168- pub const SIG_IGN : u8 = 2 ;
169- pub const SIG_DFL : u8 = 3 ;
170- }
171-
172- let ( on_broken_pipe_used, handler) = match sigpipe {
173- sigpipe:: DEFAULT => ( false , Some ( libc:: SIG_IGN ) ) ,
174- sigpipe:: INHERIT => ( true , None ) ,
175- sigpipe:: SIG_IGN => ( true , Some ( libc:: SIG_IGN ) ) ,
176- sigpipe:: SIG_DFL => ( true , Some ( libc:: SIG_DFL ) ) ,
177- _ => unreachable ! ( ) ,
161+ use crate :: io:: OnBrokenPipe ;
162+ let ( on_broken_pipe_used, handler) = match crate :: io:: on_broken_pipe ( ) {
163+ OnBrokenPipe :: BackwardsCompatible => ( false , Some ( libc:: SIG_IGN ) ) ,
164+ OnBrokenPipe :: Inherit => ( true , None ) ,
165+ OnBrokenPipe :: Error => ( true , Some ( libc:: SIG_IGN ) ) ,
166+ OnBrokenPipe :: Kill => ( true , Some ( libc:: SIG_DFL ) ) ,
178167 } ;
179168 if on_broken_pipe_used {
180169 ON_BROKEN_PIPE_USED . store ( true , crate :: sync:: atomic:: Ordering :: Relaxed ) ;
0 commit comments