| 664 | // faulthandler_enable |
| 665 | #[cfg(unix)] |
| 666 | fn faulthandler_enable_internal() -> bool { |
| 667 | if FATAL_ERROR.enabled.load(Ordering::Relaxed) { |
| 668 | return true; |
| 669 | } |
| 670 | |
| 671 | unsafe { |
| 672 | for handler in FAULTHANDLER_HANDLERS.iter_mut() { |
| 673 | if handler.enabled { |
| 674 | continue; |
| 675 | } |
| 676 | |
| 677 | let mut action: libc::sigaction = core::mem::zeroed(); |
| 678 | action.sa_sigaction = faulthandler_fatal_error as *const () as libc::sighandler_t; |
| 679 | // SA_NODEFER flag |
| 680 | action.sa_flags = libc::SA_NODEFER; |
| 681 | |
| 682 | if libc::sigaction(handler.signum, &action, &mut handler.previous) != 0 { |
| 683 | return false; |
| 684 | } |
| 685 | |
| 686 | handler.enabled = true; |
| 687 | } |
| 688 | } |
| 689 | |
| 690 | FATAL_ERROR.enabled.store(true, Ordering::Relaxed); |
| 691 | true |
| 692 | } |
| 693 | |
| 694 | #[cfg(windows)] |
| 695 | fn faulthandler_enable_internal() -> bool { |