(signum: i32)
| 678 | |
| 679 | #[cfg(any(unix, windows))] |
| 680 | pub extern "C" fn run_signal(signum: i32) { |
| 681 | signal::TRIGGERS[signum as usize].store(true, Ordering::Relaxed); |
| 682 | signal::set_triggered(); |
| 683 | #[cfg(windows)] |
| 684 | if signum == libc::SIGINT |
| 685 | && let Some(handle) = signal::get_sigint_event() |
| 686 | { |
| 687 | unsafe { |
| 688 | windows_sys::Win32::System::Threading::SetEvent(handle as _); |
| 689 | } |
| 690 | } |
| 691 | let wakeup_fd = WAKEUP.load(Ordering::Relaxed); |
| 692 | if wakeup_fd != INVALID_WAKEUP { |
| 693 | let sigbyte = signum as u8; |
| 694 | #[cfg(windows)] |
| 695 | if WAKEUP_IS_SOCKET.load(Ordering::Relaxed) { |
| 696 | let _res = unsafe { |
| 697 | windows_sys::Win32::Networking::WinSock::send( |
| 698 | wakeup_fd, |
| 699 | &sigbyte as *const u8 as *const _, |
| 700 | 1, |
| 701 | 0, |
| 702 | ) |
| 703 | }; |
| 704 | return; |
| 705 | } |
| 706 | let _res = unsafe { libc::write(wakeup_fd as _, &sigbyte as *const u8 as *const _, 1) }; |
| 707 | // TODO: handle _res < 1, support warn_on_full_buffer |
| 708 | } |
| 709 | } |
| 710 | |
| 711 | /// Reset wakeup fd after fork in child process. |
| 712 | /// The child must not write to the parent's wakeup fd. |
no test coverage detected