File tree 2 files changed +8
-9
lines changed
2 files changed +8
-9
lines changed Original file line number Diff line number Diff line change @@ -406,6 +406,7 @@ impl TryFrom<libc::c_int> for Errno {
406
406
}
407
407
408
408
pub fn get_current_errno_value ( ) -> Errno {
409
- let errno = unsafe { * libc:: __errno_location ( ) } ;
409
+ // guaranteed to be some, unwrap is safe
410
+ let errno = std:: io:: Error :: last_os_error ( ) . raw_os_error ( ) . unwrap ( ) ;
410
411
errno. try_into ( ) . expect ( "invalid errno value" )
411
412
}
Original file line number Diff line number Diff line change @@ -270,16 +270,14 @@ fn get_pending_signal() -> Option<Signal> {
270
270
}
271
271
272
272
unsafe fn handle_signal ( signal : Signal , handler : libc:: sighandler_t ) {
273
- let mut empty_sigset: libc:: sigset_t = std:: mem:: zeroed :: < libc:: sigset_t > ( ) ;
273
+ // sigaction contains different field on different systems, we can't
274
+ // initialize it directly
275
+ let mut action = std:: mem:: zeroed :: < libc:: sigaction > ( ) ;
276
+ action. sa_sigaction = handler;
274
277
// never fails
275
- libc:: sigemptyset ( & mut empty_sigset) ;
278
+ libc:: sigemptyset ( & mut action. sa_mask ) ;
279
+ action. sa_flags = libc:: SA_SIGINFO ;
276
280
277
- let action = libc:: sigaction {
278
- sa_sigaction : handler,
279
- sa_mask : empty_sigset,
280
- sa_flags : libc:: SA_SIGINFO ,
281
- sa_restorer : None ,
282
- } ;
283
281
let result = libc:: sigaction ( signal. into ( ) , & action, std:: ptr:: null_mut ( ) ) ;
284
282
if result < 0 {
285
283
panic ! ( "failed to set signal handler" )
You can’t perform that action at this time.
0 commit comments